CPU specific definitions for internal peripheral handling. More...
CPU specific definitions for internal peripheral handling.
Definition in file periph_cpu.h.
#include <inttypes.h>#include "cpu.h"#include "clic.h"#include "kernel_defines.h"#include "macros/units.h"
Include dependency graph for periph_cpu.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| union | gpio_conf_gd32v |
| GPIO pin configuration for GD32V MCUs. More... | |
| struct | adc_conf_t |
| ADC device configuration. More... | |
| struct | dac_conf_t |
| DAC line configuration data. More... | |
| struct | timer_conf_t |
| Timer device configuration. More... | |
| struct | uart_conf_t |
| UART device configuration. More... | |
| struct | spi_conf_t |
| SPI device configuration. More... | |
| struct | i2c_conf_t |
| I2C configuration structure. More... | |
| struct | pwm_chan_t |
| PWM channel. More... | |
| struct | pwm_conf_t |
| PWM device configuration. More... | |
Macros | |
| #define | ADC_DEVS (2U) |
| Available number of ADC devices. | |
| #define | DAC_CHANNEL_NUMOF (2) |
| GD32V DAC has 2 channels. | |
| #define | TIMER_CHANNEL_NUMOF (4U) |
| GD32V timers have 4 capture-compare channels. | |
| #define | TIMER_CHANNEL(tim, chan) *(&dev(tim)->CH0CV + (chan * 2)) |
| Macro for accessing the capture/compare register of a timer channel. | |
| #define | UART_ISR_PRIO (2) |
| UART interrupt priority. | |
| #define | SPI_HWCS_MASK (0xffffff00) |
| Define a magic number that tells us to use hardware chip select. More... | |
| #define | SPI_HWCS(x) (SPI_HWCS_MASK | x) |
| Override the default SPI hardware chip select access macro. More... | |
| #define | SPI_CS_UNDEF (GPIO_UNDEF) |
| Define value for unused CS line. | |
| #define | WDT_INTR_PRIORITY (PLIC_NUM_PRIORITIES) |
| WDT interrupt priority: use highest priority. | |
| #define | WDT_HAS_STOP (0) |
| No brakes on the WDT train. | |
Enumerations | |
| enum | bus_t { AHB , APB1 , APB2 , BUS_NUMOF } |
| On-Chip buses. More... | |
| enum | |
| Available GPIO ports. | |
| enum | gpio_af_t { GPIO_AF_OUT_PP = 0xb , GPIO_AF_OUT_OD = 0xf , GPIO_AF0 = 0 , GPIO_AF1 , GPIO_AF2 , GPIO_AF3 , GPIO_AF4 , GPIO_AF5 , GPIO_AF6 , GPIO_AF7 , GPIO_AF8 , GPIO_AF9 , GPIO_AF10 , GPIO_AF11 , GPIO_AF12 , GPIO_AF13 , GPIO_AF14 , GPIO_AF15 , GPIO_AF_UNDEF } |
| Override alternative GPIO mode options. More... | |
Functions | |
| void | gpio_init_af (gpio_t pin, gpio_af_t af) |
| Configure the alternate function for the given pin. More... | |
| void | gpio_init_analog (gpio_t pin) |
| Configure the given pin to be used as ADC input. More... | |
| void | periph_clk_en (bus_t bus, uint32_t mask) |
| Enable the given peripheral clock. More... | |
| void | periph_clk_dis (bus_t bus, uint32_t mask) |
| Disable the given peripheral clock. More... | |
| uint32_t | periph_apb_clk (bus_t bus) |
| Get the actual bus clock frequency for the APB buses. More... | |
| void | gd32vf103_clock_init (void) |
| void | gd32v_enable_irc8 (void) |
| void | gd32v_disable_irc8 (void) |
Power management configuration | |
| #define | PM_NUM_MODES (3U) |
| Number of usable low power modes. More... | |
| #define | CONFIG_PM_EWUP_USED (0U) |
| Wake-up pin used. | |
| enum | { GD32V_PM_STANDBY = 0 , GD32V_PM_DEEPSLEEP = 1 , GD32V_PM_IDLE = 2 } |
| Power modes. More... | |
| #define | PERIPH_SPI_NEEDS_TRANSFER_BYTE |
| Use the shared SPI functions. More... | |
| #define | PERIPH_SPI_NEEDS_TRANSFER_REG |
| Use transfer reg function from periph common. | |
| #define | PERIPH_SPI_NEEDS_TRANSFER_REGS |
| Use transfer regs function from periph common. | |
| #define | HAVE_SPI_CLK_T |
| Override SPI clock speed values. | |
| enum | { SPI_CLK_100KHZ = KHZ(100) , SPI_CLK_400KHZ = KHZ(400) , SPI_CLK_1MHZ = MHZ(1) , SPI_CLK_5MHZ = MHZ(5) , SPI_CLK_10MHZ = MHZ(10) } |
| typedef uint32_t | spi_clk_t |
| SPI clock type. | |
Use the shared I2C functions | |
| #define | PERIPH_I2C_NEED_READ_REG |
| Use read reg function from periph common. | |
| #define | PERIPH_I2C_NEED_WRITE_REG |
| Use write reg function from periph common. | |
| #define | PERIPH_I2C_NEED_READ_REGS |
| Use read regs function from periph common. | |
| #define | PERIPH_I2C_NEED_WRITE_REGS |
| Use write regs function from periph common. | |
WDT upper and lower bound times in ms | |
| #define | NWDT_TIME_LOWER_LIMIT (1) |
| #define | NWDT_TIME_UPPER_LIMIT ((UINT32_MAX >> 15) * MS_PER_SEC + 1) |
RTT/RTC configuration | |
| #define | RTT_DEV RTC |
| RTC is used as RTT device. | |
| #define | RTT_IRQ RTC_ALARM_IRQn |
| RTC_ALARM_IRQn is used as IRQ number. | |
| #define | RTT_IRQ_PRIORITY (2) |
| RTT interrupt priority. | |
| #define | RTT_MAX_VALUE (0xffffffff) |
| maximum RTT value | |
| #define | RTT_MIN_FREQUENCY (1U) |
| minimum RTT frequency in Hz | |
USB device definitions | |
| #define | USBDEV_SET_ADDR_AFTER_STATUS 0 |
| Set device address after SETUP stage. | |
| #define | USBDEV_NUM_ENDPOINTS 4 |
| Number of USB OTG FS endpoints including EP0. | |
| #define PERIPH_SPI_NEEDS_TRANSFER_BYTE |
Use the shared SPI functions.
Use transfer byte function from periph common
Definition at line 376 of file periph_cpu.h.
| #define PM_NUM_MODES (3U) |
Number of usable low power modes.
Number of usable low power modes
Definition at line 38 of file periph_cpu.h.
| #define SPI_HWCS | ( | x | ) | (SPI_HWCS_MASK | x) |
Override the default SPI hardware chip select access macro.
Since the CPU does only support one single hardware chip select line, we can detect the usage of non-valid lines by comparing to SPI_HWCS_VALID.
Definition at line 354 of file periph_cpu.h.
| #define SPI_HWCS_MASK (0xffffff00) |
Define a magic number that tells us to use hardware chip select.
We use a random value here, that does clearly differentiate from any possible GPIO_PIN(x) value.
Definition at line 346 of file periph_cpu.h.
| anonymous enum |
Power modes.
The GD32V has three power modes (terminology as defined by GigaDevice).
| Enumerator | |
|---|---|
| GD32V_PM_STANDBY | STANDBY mode, |
| GD32V_PM_DEEPSLEEP | DEEPSLEEP mode, corresponds to STOP mode of STM32. |
| GD32V_PM_IDLE | IDLE mode. |
Definition at line 56 of file periph_cpu.h.
| anonymous enum |
Definition at line 388 of file periph_cpu.h.
| enum bus_t |
On-Chip buses.
| Enumerator | |
|---|---|
| AHB | Advanced High-performance Bus. |
| APB1 | Advanced Peripheral Bus 1 |
| APB2 | Advanced Peripheral Bus 2 |
| BUS_NUMOF | number of buses |
Definition at line 73 of file periph_cpu.h.
| enum gpio_af_t |
Override alternative GPIO mode options.
Definition at line 162 of file periph_cpu.h.
Configure the alternate function for the given pin.
| [in] | pin | pin to configure |
| [in] | af | alternate function to use |
| void gpio_init_analog | ( | gpio_t | pin | ) |
Configure the given pin to be used as ADC input.
| [in] | pin | pin to configure |
| uint32_t periph_apb_clk | ( | bus_t | bus | ) |
Get the actual bus clock frequency for the APB buses.
| [in] | bus | target APBx bus |
| void periph_clk_dis | ( | bus_t | bus, |
| uint32_t | mask | ||
| ) |
Disable the given peripheral clock.
| [in] | bus | bus the peripheral is connected to |
| [in] | mask | bit in the RCU enable register |
| void periph_clk_en | ( | bus_t | bus, |
| uint32_t | mask | ||
| ) |
Enable the given peripheral clock.
| [in] | bus | bus the peripheral is connected to |
| [in] | mask | bit in the RCU enable register |