Software APIs
dt_api.c File Reference

Device Tables (DT) API for top englishbreakfast. More...

#include "dt/dt_api.h"
#include "hw/top_englishbreakfast/sw/autogen/top_englishbreakfast.h"
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  dt_pad_desc
 Pad description. More...
 

Macros

#define TRY_GET_PAD(pad, default)
 

Typedefs

typedef struct dt_pad_desc dt_pad_desc_t
 Pad description.
 

Enumerations

enum  { kTopEnglishbreakfastPlicIrqIdCount = kTopEnglishbreakfastPlicIrqIdLast + 1 }
 

Functions

dt_instance_id_t dt_plic_id_to_instance_id (dt_plic_irq_id_t irq)
 Get the instance ID for a given PLIC IRQ ID.
 
dt_device_type_t dt_device_type (dt_instance_id_t dev)
 Get the instance type of a device instance.
 
dt_pad_type_t dt_pad_type (dt_pad_t pad)
 Return the type of a dt_pad_t.
 
dt_pinmux_mio_out_t dt_pad_mio_out (dt_pad_t pad)
 Return the pad out number for an MIO pad.
 
dt_pinmux_muxed_pad_t dt_pad_mio_pad_index (dt_pad_t pad)
 Return the pad out number for an MIO pad.
 
dt_pinmux_insel_t dt_pad_mio_insel (dt_pad_t pad)
 Return the insel for an MIO pad.
 
dt_pinmux_direct_pad_t dt_pad_dio_pad_index (dt_pad_t pad)
 Return the direct pad number of a DIO pad.
 

Variables

const dt_periph_io_t kDtPeriphIoConstantHighZ
 
const dt_periph_io_t kDtPeriphIoConstantZero
 
const dt_periph_io_t kDtPeriphIoConstantOne
 

Detailed Description

Device Tables (DT) API for top englishbreakfast.

Definition in file dt_api.c.


Data Structure Documentation

◆ dt_pad_desc

struct dt_pad_desc

Pad description.

A dt_pad_t represents a chip's physical pad.

Definition at line 357 of file dt_api.c.

Data Fields
uint16_t insel For kDtPadTypeMio pads: MIO pad number.

This is the value to put in the MIO_PERIPH_INSEL registers to connect a peripheral to this pad.

uint16_t mio_out_or_direct_pad For kDtPadTypeMio pads: MIO out number.

This is the index of the MIO_OUTSEL register that controls this pad (or the output part of this pad).

For kDtPadTypeDio: DIO pad number. This is the index of the various DIO_PAD_* registers that control this pad.

dt_pad_type_t type Pad type.

Macro Definition Documentation

◆ TRY_GET_PAD

#define TRY_GET_PAD ( pad,
default )
Value:
({ if ((pad) < (dt_pad_t)0 || (pad) >= kDtPadCount) return (default); &dt_pad[pad]; })

Definition at line 484 of file dt_api.c.

Typedef Documentation

◆ dt_pad_desc_t

typedef struct dt_pad_desc dt_pad_desc_t

Pad description.

A dt_pad_t represents a chip's physical pad.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 18 of file dt_api.c.

Function Documentation

◆ dt_device_type()

Get the instance type of a device instance.

For example the instance type of kDtUart0 is kDtInstanceTypeUart.

Parameters
idAn instance ID.
Returns
The instance type, or kDtInstanceIdUnknown if the ID is not valid.

Definition at line 142 of file dt_api.c.

◆ dt_pad_dio_pad_index()

dt_pinmux_direct_pad_t dt_pad_dio_pad_index ( dt_pad_t pad)

Return the direct pad number of a DIO pad.

This is the index of the various DIO_PAD_* registers that control this pad.

Parameters
padA pad of type kDtPadTypeDio.
Returns
The direct pad number of the DID that this pad is connected to.

Note: This function only makes sense for pads of type kDtPeriphIoTypeDio which are either outputs or inouts. For any other pad type, the return value is unspecified.

Definition at line 503 of file dt_api.c.

◆ dt_pad_mio_insel()

dt_pinmux_insel_t dt_pad_mio_insel ( dt_pad_t pad)

Return the insel for an MIO pad.

This is the value to put in the MIO_PERIPH_INSEL registers to connect a peripheral I/O to this pad.

Parameters
padA pad of type kDtPadTypeMio.
Returns
The insel of the MIO that this pad is connected to.

Note: This function only makes sense for pads of type kDtPadTypeMio. For any other pad, the return value is unspecified.

Definition at line 499 of file dt_api.c.

◆ dt_pad_mio_out()

dt_pinmux_mio_out_t dt_pad_mio_out ( dt_pad_t pad)

Return the pad out number for an MIO pad.

This is the index of the MIO_OUT registers that control this pad (or the output part of this pad).

Parameters
padA pad of type kDtPadTypeMio.
Returns
The pad out number of the MIO.

Note: This function only makes sense for pads of type kDtPadTypeMio which are either inputs or inouts. For any other pad, the return value is unspecified.

Definition at line 490 of file dt_api.c.

◆ dt_pad_mio_pad_index()

dt_pinmux_muxed_pad_t dt_pad_mio_pad_index ( dt_pad_t pad)

Return the pad out number for an MIO pad.

This is the index of the MIO_PAD registers that control this pad (or the output part of this pad).

Parameters
padA pad of type kDtPadTypeMio.
Returns
The pad out number of the MIO.

Note: This function only makes sense for pads of type kDtPadTypeMio. For any other pad, the return value is unspecified.

Definition at line 494 of file dt_api.c.

◆ dt_pad_type()

Return the type of a dt_pad_t.

Parameters
padA pad description.
Returns
The pad type (MIO, DIO, etc).

Definition at line 486 of file dt_api.c.

◆ dt_plic_id_to_instance_id()

dt_instance_id_t dt_plic_id_to_instance_id ( dt_plic_irq_id_t irq)

Get the instance ID for a given PLIC IRQ ID.

For example, on earlgrey, the instance ID of kTopEarlgreyPlicIrqIdUart0TxWatermark is kDtInstanceIdUart0. One can then use the type specific function to retrieve the IRQ name, for example dt_uart_irq_from_plic_id for the UART.

Parameters
irqA PLIC ID.
Returns
The instance ID, or kDtInstanceIdUnknown if the PLIC ID is not valid.

Definition at line 113 of file dt_api.c.

Variable Documentation

◆ kDtPeriphIoConstantHighZ

const dt_periph_io_t kDtPeriphIoConstantHighZ
Initial value:
= {
.__internal = {
.periph_input_or_direct_pad = 0,
.outsel_or_dt_pad = kDtPinmuxOutselConstantHighZ,
}
}

Definition at line 508 of file dt_api.c.

◆ kDtPeriphIoConstantOne

const dt_periph_io_t kDtPeriphIoConstantOne
Initial value:
= {
.__internal = {
.periph_input_or_direct_pad = 0,
.outsel_or_dt_pad = kDtPinmuxOutselConstantOne,
}
}

Definition at line 526 of file dt_api.c.

◆ kDtPeriphIoConstantZero

const dt_periph_io_t kDtPeriphIoConstantZero
Initial value:
= {
.__internal = {
.periph_input_or_direct_pad = 0,
.outsel_or_dt_pad = kDtPinmuxOutselConstantZero,
}
}

Definition at line 517 of file dt_api.c.