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"
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. | |
#define | SPI_HWCS(x) (SPI_HWCS_MASK | x) |
Override the default SPI hardware chip select access macro. | |
#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 } |
On-Chip buses. More... | |
enum | |
Available GPIO ports. More... | |
enum | gpio_af_t { GPIO_AF_OUT_PP = 0xb , GPIO_AF_OUT_OD = 0xf } |
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. | |
void | gpio_init_analog (gpio_t pin) |
Configure the given pin to be used as ADC input. | |
void | periph_clk_en (bus_t bus, uint32_t mask) |
Enable the given peripheral clock. | |
void | periph_clk_dis (bus_t bus, uint32_t mask) |
Disable the given peripheral clock. | |
uint32_t | periph_apb_clk (bus_t bus) |
Get the actual bus clock frequency for the APB buses. | |
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. | |
#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. | |
#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 ADC_DEVS (2U) |
Available number of ADC devices.
Definition at line 282 of file periph_cpu.h.
#define CONFIG_PM_EWUP_USED (0U) |
Wake-up pin used.
Definition at line 70 of file periph_cpu.h.
#define DAC_CHANNEL_NUMOF (2) |
GD32V DAC has 2 channels.
Definition at line 296 of file periph_cpu.h.
#define HAVE_SPI_CLK_T |
Override SPI clock speed values.
Definition at line 391 of file periph_cpu.h.
#define NWDT_TIME_LOWER_LIMIT (1) |
Definition at line 493 of file periph_cpu.h.
#define NWDT_TIME_UPPER_LIMIT ((UINT32_MAX >> 15) * MS_PER_SEC + 1) |
Definition at line 498 of file periph_cpu.h.
#define PERIPH_I2C_NEED_READ_REG |
Use read reg function from periph common.
Definition at line 430 of file periph_cpu.h.
#define PERIPH_I2C_NEED_READ_REGS |
Use read regs function from periph common.
Definition at line 434 of file periph_cpu.h.
#define PERIPH_I2C_NEED_WRITE_REG |
Use write reg function from periph common.
Definition at line 432 of file periph_cpu.h.
#define PERIPH_I2C_NEED_WRITE_REGS |
Use write regs function from periph common.
Definition at line 436 of file periph_cpu.h.
#define PERIPH_SPI_NEEDS_TRANSFER_BYTE |
Use the shared SPI functions.
Use transfer byte function from periph common
Definition at line 380 of file periph_cpu.h.
#define PERIPH_SPI_NEEDS_TRANSFER_REG |
Use transfer reg function from periph common.
Definition at line 382 of file periph_cpu.h.
#define PERIPH_SPI_NEEDS_TRANSFER_REGS |
Use transfer regs function from periph common.
Definition at line 384 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 42 of file periph_cpu.h.
#define RTT_DEV RTC |
RTC is used as RTT device.
Definition at line 515 of file periph_cpu.h.
#define RTT_IRQ RTC_ALARM_IRQn |
RTC_ALARM_IRQn is used as IRQ number.
Definition at line 517 of file periph_cpu.h.
#define RTT_IRQ_PRIORITY (2) |
RTT interrupt priority.
Definition at line 518 of file periph_cpu.h.
#define RTT_MAX_VALUE (0xffffffff) |
maximum RTT value
Definition at line 519 of file periph_cpu.h.
#define RTT_MIN_FREQUENCY (1U) |
minimum RTT frequency in Hz
Definition at line 521 of file periph_cpu.h.
#define SPI_CS_UNDEF (GPIO_UNDEF) |
Define value for unused CS line.
Definition at line 363 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 358 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 350 of file periph_cpu.h.
#define TIMER_CHANNEL | ( | tim, | |
chan | |||
) | *(&dev(tim)->CH0CV + (chan * 2)) |
Macro for accessing the capture/compare register of a timer channel.
Definition at line 314 of file periph_cpu.h.
#define TIMER_CHANNEL_NUMOF (4U) |
GD32V timers have 4 capture-compare channels.
Definition at line 309 of file periph_cpu.h.
#define UART_ISR_PRIO (2) |
UART interrupt priority.
Definition at line 342 of file periph_cpu.h.
#define USBDEV_NUM_ENDPOINTS 4 |
Number of USB OTG FS endpoints including EP0.
Definition at line 529 of file periph_cpu.h.
#define USBDEV_SET_ADDR_AFTER_STATUS 0 |
Set device address after SETUP stage.
Definition at line 528 of file periph_cpu.h.
#define WDT_HAS_STOP (0) |
No brakes on the WDT train.
Definition at line 509 of file periph_cpu.h.
#define WDT_INTR_PRIORITY (PLIC_NUM_PRIORITIES) |
WDT interrupt priority: use highest priority.
Definition at line 504 of file periph_cpu.h.
typedef uint32_t spi_clk_t |
SPI clock type.
Definition at line 403 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 60 of file periph_cpu.h.
anonymous enum |
Available GPIO ports.
Definition at line 86 of file periph_cpu.h.
anonymous enum |
Definition at line 392 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 |
Definition at line 77 of file periph_cpu.h.
enum gpio_af_t |
Override alternative GPIO mode options.
Enumerator | |
---|---|
GPIO_AF_OUT_PP | alternate function output - push-pull |
GPIO_AF_OUT_OD | alternate function output - open-drain |
Definition at line 166 of file periph_cpu.h.
void gpio_init_af | ( | gpio_t | pin, |
gpio_af_t | af | ||
) |
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 |