Peripheral base framework

yasimavr: Peripheral base framework
yasimavr
Loading...
Searching...
No Matches
Peripheral base framework

Classes

struct  NVM_request_t
 Structure used for AVR_CTLREQ_NVM_REQUEST requests. More...
 
struct  ctlreq_data_t
 
struct  base_reg_config_t
 
class  Peripheral
 Abstract class defining a framework for MCU peripherals. More...
 

Controller requests definition

Definition of common and builtin CTLREQs

See also
Device::ctlreq
ctlreq_data_t
typedef int ctlreq_id_t
 
#define AVR_CTLREQ_BASE   0x100
 
#define AVR_CTLREQ_GET_SIGNAL   0
 
#define AVR_CTLREQ_CORE_BREAK   (AVR_CTLREQ_BASE + 1)
 
#define AVR_CTLREQ_CORE_SLEEP   (AVR_CTLREQ_BASE + 2)
 
#define AVR_CTLREQ_CORE_WAKEUP   (AVR_CTLREQ_BASE + 3)
 
#define AVR_CTLREQ_CORE_SHORTING   (AVR_CTLREQ_BASE + 4)
 
#define AVR_CTLREQ_CORE_CRASH   (AVR_CTLREQ_BASE + 5)
 
#define AVR_CTLREQ_CORE_RESET   (AVR_CTLREQ_BASE + 6)
 
#define AVR_CTLREQ_CORE_RESET_FLAG   (AVR_CTLREQ_BASE + 7)
 
#define AVR_CTLREQ_CORE_NVM   (AVR_CTLREQ_BASE + 8)
 
#define AVR_CTLREQ_CORE_HALT   (AVR_CTLREQ_BASE + 9)
 
#define AVR_CTLREQ_CORE_SECTIONS   (AVR_CTLREQ_BASE + 10)
 
#define AVR_CTLREQ_WATCHDOG_RESET   (AVR_CTLREQ_BASE + 1)
 
#define AVR_CTLREQ_NVM_REQUEST   (AVR_CTLREQ_BASE + 1)
 
#define AVR_CTLREQ_SLEEP_CALL   (AVR_CTLREQ_BASE + 1)
 
#define AVR_CTLREQ_SLEEP_PSEUDO   (AVR_CTLREQ_BASE + 2)
 

Peripheral identifier definition

All peripherals are uniquely identified by a 32-bits integer which is actually composed of 4 characters. This section defines the identifiers for the usual peripherals.

See also
Peripheral
constexpr sim_id_t AVR_IOCTL_CORE = "CORE"
 
constexpr sim_id_t AVR_IOCTL_WDT = "WDT"
 
constexpr sim_id_t AVR_IOCTL_INTR = "CPUINT"
 
constexpr sim_id_t AVR_IOCTL_SLEEP = "SLPCTRL"
 
constexpr sim_id_t AVR_IOCTL_CLOCK = "CLKCTRL"
 
constexpr sim_id_t AVR_IOCTL_PORTMUX = "PORTMUX"
 
constexpr sim_id_t AVR_IOCTL_EEPROM = "EEPROM"
 
constexpr sim_id_t AVR_IOCTL_NVM = "NVMCTRL"
 
constexpr sim_id_t AVR_IOCTL_VREF = "VREF"
 
constexpr sim_id_t AVR_IOCTL_EXTINT = "EXTINT"
 
constexpr sim_id_t AVR_IOCTL_RST = "RSTCTRL"
 
constexpr sim_id_t AVR_IOCTL_RTC = "RTC"
 
constexpr sim_id_t AVR_IOCTL_PORT (char c)
 
constexpr sim_id_t AVR_IOCTL_ADC (char c)
 
constexpr sim_id_t AVR_IOCTL_ACP (char c)
 
constexpr sim_id_t AVR_IOCTL_TIMER (char t, char c)
 
constexpr sim_id_t AVR_IOCTL_UART (char c)
 
constexpr sim_id_t AVR_IOCTL_SPI (char c)
 
constexpr sim_id_t AVR_IOCTL_TWI (char c)
 

Register field lookup

The structure base_reg_config_t and the functions find_reg_config() are useful for configuration that maps a register field value to a set of parameters. (see the timer classes for examples)

template<typename T >
int find_reg_config (const std::vector< T > &v, uint64_t reg_value)
 
template<typename T >
const T * find_reg_config_p (const std::vector< T > &v, uint64_t reg_value)
 

Detailed Description

Macro Definition Documentation

◆ AVR_CTLREQ_BASE

#define AVR_CTLREQ_BASE   0x100

Base value for peripheral-specific requests. The range 0-255 is reserved for generic requests

◆ AVR_CTLREQ_CORE_BREAK

#define AVR_CTLREQ_CORE_BREAK   (AVR_CTLREQ_BASE + 1)

Request sent by the CPU to the core when a BREAK instruction is executed, no data provided.

◆ AVR_CTLREQ_CORE_CRASH

#define AVR_CTLREQ_CORE_CRASH   (AVR_CTLREQ_BASE + 5)

Request sent to the core to crash.

  • data.index is the reason code,
  • data.p is the optional reason string

◆ AVR_CTLREQ_CORE_HALT

#define AVR_CTLREQ_CORE_HALT   (AVR_CTLREQ_BASE + 9)

Request to halt the CPU, used during a SPM instruction. a non-zero data.u enables the halt, data.u == 0 disables the halt.

◆ AVR_CTLREQ_CORE_NVM

#define AVR_CTLREQ_CORE_NVM   (AVR_CTLREQ_BASE + 8)

Request sent to the core to query the pointer to a NVM block

  • data.index indicates which block with one of the AVR_NVM enum values

◆ AVR_CTLREQ_CORE_RESET

#define AVR_CTLREQ_CORE_RESET   (AVR_CTLREQ_BASE + 6)

Request sent to the core to trigger a MCU reset.

  • data.u is the corresponding ResetFlag enum value

◆ AVR_CTLREQ_CORE_RESET_FLAG

#define AVR_CTLREQ_CORE_RESET_FLAG   (AVR_CTLREQ_BASE + 7)

Request sent to the core to query the latest cause of reset.

  • data.u is set to the ResetFlag enum value

◆ AVR_CTLREQ_CORE_SECTIONS

#define AVR_CTLREQ_CORE_SECTIONS   (AVR_CTLREQ_BASE + 10)

Request to get the section manager. data.p is returned pointing to the instance of MemorySectionManager.

◆ AVR_CTLREQ_CORE_SHORTING

#define AVR_CTLREQ_CORE_SHORTING   (AVR_CTLREQ_BASE + 4)

Request sent by the Port Controller to the core when a pin shorting is detected

◆ AVR_CTLREQ_CORE_SLEEP

#define AVR_CTLREQ_CORE_SLEEP   (AVR_CTLREQ_BASE + 2)

Request sent by the Sleep Controller to the core to enter a sleep mode

  • data.u contains the sleep mode enum value

◆ AVR_CTLREQ_CORE_WAKEUP

#define AVR_CTLREQ_CORE_WAKEUP   (AVR_CTLREQ_BASE + 3)

Request sent by the Sleep Controller to the core to wake up from a sleep mode, no data provided

◆ AVR_CTLREQ_GET_SIGNAL

#define AVR_CTLREQ_GET_SIGNAL   0

Common request identifier used to obtain a pointer to a particular signal

  • data.index should contain the identifier of the signal
  • data.p is returned pointing to the signal

◆ AVR_CTLREQ_NVM_REQUEST

#define AVR_CTLREQ_NVM_REQUEST   (AVR_CTLREQ_BASE + 1)

Request sent by the CPU to the NVM controller when executing a SPM instruction, or a LPM instruction if the LPM direct mode is disabled with the core.

  • data.p points to a NVM_request_t structure filled with the instruction information

◆ AVR_CTLREQ_SLEEP_CALL

#define AVR_CTLREQ_SLEEP_CALL   (AVR_CTLREQ_BASE + 1)

Request sent by the CPU to the Sleep Controller when executing a SLEEP instruction, no data provided

◆ AVR_CTLREQ_SLEEP_PSEUDO

#define AVR_CTLREQ_SLEEP_PSEUDO   (AVR_CTLREQ_BASE + 2)

Request sent by the CPU to the Sleep Controller when executing a "RJMP .-2" instruction, no data provided

◆ AVR_CTLREQ_WATCHDOG_RESET

#define AVR_CTLREQ_WATCHDOG_RESET   (AVR_CTLREQ_BASE + 1)

Request sent by the CPU to the watchdog when executing a WDR instruction, no data provided

Typedef Documentation

◆ ctlreq_id_t

typedef int ctlreq_id_t

CTLREQ identifier type

Function Documentation

◆ AVR_IOCTL_ACP()

constexpr sim_id_t AVR_IOCTL_ACP ( char  c)
constexpr

CTLID for the analog comparator: "ACPn", n=0,1,...

◆ AVR_IOCTL_ADC()

constexpr sim_id_t AVR_IOCTL_ADC ( char  c)
constexpr

CTLID for the analog-to-digital converter: "ADCn", n=0,1,...

◆ AVR_IOCTL_PORT()

constexpr sim_id_t AVR_IOCTL_PORT ( char  c)
constexpr

CTLID for the I/O port controller: "PORTx" x='A','B',...

◆ AVR_IOCTL_SPI()

constexpr sim_id_t AVR_IOCTL_SPI ( char  c)
constexpr

CTLID for the SPI interface: "SPIn"

◆ AVR_IOCTL_TIMER()

constexpr sim_id_t AVR_IOCTL_TIMER ( char  t,
char  c 
)
constexpr

CTLID for the timer/counter: "TCtn", t='A','B'; n=0,1,...

◆ AVR_IOCTL_TWI()

constexpr sim_id_t AVR_IOCTL_TWI ( char  c)
constexpr

CTLID for the TWI interface: "TWIn"

◆ AVR_IOCTL_UART()

constexpr sim_id_t AVR_IOCTL_UART ( char  c)
constexpr

CTLID for the USART interface: "USARTn"

◆ find_reg_config()

template<typename T >
int find_reg_config ( const std::vector< T > &  v,
uint64_t  reg_value 
)

◆ find_reg_config_p()

template<typename T >
const T * find_reg_config_p ( const std::vector< T > &  v,
uint64_t  reg_value 
)

Variable Documentation

◆ AVR_IOCTL_CLOCK

constexpr sim_id_t AVR_IOCTL_CLOCK = "CLKCTRL"
constexpr

CTLID for the clock controller: "CLKCTRL"

◆ AVR_IOCTL_CORE

constexpr sim_id_t AVR_IOCTL_CORE = "CORE"
constexpr

CTLID for the core: "CORE"

◆ AVR_IOCTL_EEPROM

constexpr sim_id_t AVR_IOCTL_EEPROM = "EEPROM"
constexpr

CTLID for the EEPROM controller: "EEPROM"

◆ AVR_IOCTL_EXTINT

constexpr sim_id_t AVR_IOCTL_EXTINT = "EXTINT"
constexpr

CTLID for the external interrupt controller: "EINT"

◆ AVR_IOCTL_INTR

constexpr sim_id_t AVR_IOCTL_INTR = "CPUINT"
constexpr

CTLID for the interrupt controller: "CPUINT"

◆ AVR_IOCTL_NVM

constexpr sim_id_t AVR_IOCTL_NVM = "NVMCTRL"
constexpr

CTLID for the NVM controller: "NVMCTRL"

◆ AVR_IOCTL_PORTMUX

constexpr sim_id_t AVR_IOCTL_PORTMUX = "PORTMUX"
constexpr

CTLID for the port mux controller

◆ AVR_IOCTL_RST

constexpr sim_id_t AVR_IOCTL_RST = "RSTCTRL"
constexpr

CTLID for the reset controller: "RSTCTRL"

◆ AVR_IOCTL_RTC

constexpr sim_id_t AVR_IOCTL_RTC = "RTC"
constexpr

CTLID for the real-time counter: "RTC"

◆ AVR_IOCTL_SLEEP

constexpr sim_id_t AVR_IOCTL_SLEEP = "SLPCTRL"
constexpr

CTLID for the sleep controller: "SLPCTRL"

◆ AVR_IOCTL_VREF

constexpr sim_id_t AVR_IOCTL_VREF = "VREF"
constexpr

CTLID for the voltage reference controller: "VREF"

◆ AVR_IOCTL_WDT

constexpr sim_id_t AVR_IOCTL_WDT = "WDT"
constexpr

CTLID for the watchdog timer: "WDT"