Go to the documentation of this file.
18 #include "stm32f4xx.h"
22 #define BIT_POS_TO_MASK(x) (0x01 << (x))
23 #define BASE_MASK_TO_POS(m, p) ((m) << (p))
24 #define GET_PIN_IRQN(pin) (pin >= 10 ? EXTI15_10_IRQn : (pin >= 5 ? EXTI9_5_IRQn : (EXTI0_IRQn + pin)))
28 #define RCC_HSI_CALIBRATION_DEFAULT 0x10U
29 #define TICK_FREQ_1KHZ 1U
30 #define NVIC_PRIORITY_GROUP_0 ((uint32_t)0x00000007)
32 #define NVIC_PRIORITY_GROUP_4 ((uint32_t)0x00000003)
36 #define POWER_REGULATOR_VOLTAGE_SCALE3 0x01
42 #define GPIO_MODE_IN 0x00
43 #define GPIO_MODE_OUT 0x01
44 #define GPIO_MODE_ALTERNATE 0x02
45 #define GPIO_MODE_ANALOG 0x03
47 #define GPIO_PUPDR_NOPULL 0x00
48 #define GPIO_PUPDR_PUP 0x01
49 #define GPIO_PUPDR_PDOWN 0x02
52 #define TRIGGER_RISING_EDGE 0x01U
53 #define TRIGGER_FALLING_EDGE 0x02U
54 #define TRIGGER_BOTH_EDGE (TRIGGER_RISING_EDGE | TRIGGER_FALLING_EDGE)
55 #define TRIGGER_ENABLE_EVENT_REQ 0x04U
56 #define TRIGGER_ENABLE_INTERR_REQ 0x08U
59 #define ADC_VREF_MV 3300U
61 #define ADC_RESOLUTION_12B (0x00U << ADC_CR1_RES_Pos)
62 #define ADC_RESOLUTION_10B (0x01U << ADC_CR1_RES_Pos)
63 #define ADC_RESOLUTION_8B (0x02U << ADC_CR1_RES_Pos)
64 #define ADC_RESOLUTION_6B (0x03U << ADC_CR1_RES_Pos)
66 #define ADC_EOC_INTERRUPT_ENABLE (0x01U << ADC_CR1_EOCIE_Pos)
void port_system_set_millis(uint32_t ms)
Sets the number of milliseconds since the system started.
void port_system_gpio_exti_disable(uint8_t pin)
Disable interrupts of a GPIO line (pin)
void port_system_adc_enable(ADC_TypeDef *p_adc)
Enable the ADC peripheral to work.
void port_system_adc_start_conversion(ADC_TypeDef *p_adc, uint8_t channel)
Start the conversion of the ADC peripheral.
void port_system_delay_ms(uint32_t ms)
Wait for some milliseconds.
void port_system_gpio_exti_enable(uint8_t pin, uint8_t priority, uint8_t subpriority)
Enable interrupts of a GPIO line (pin)
void port_system_adc_interrupt_enable(uint8_t priority, uint8_t subpriority)
Enable the ADC global interrupts in NVIC. ADC1, ADC2, and ADC3 share the same interrupt.
void port_system_adc_single_ch_init(ADC_TypeDef *p_adc, uint8_t channel, uint32_t cr_mode)
Configure the ADC peripheral for a single channel.
uint32_t port_system_get_millis(void)
Get the count of the System tick in milliseconds.
void port_system_gpio_config(GPIO_TypeDef *p_port, uint8_t pin, uint8_t mode, uint8_t pupd)
Configure the mode and pull of a GPIO.
void port_system_adc_disable(ADC_TypeDef *p_adc)
Disable the ADC peripheral.
void port_system_gpio_config_exti(GPIO_TypeDef *p_port, uint8_t pin, uint32_t mode)
Configure the external interruption or event of a GPIO.
void port_system_delay_until_ms(uint32_t *p_t, uint32_t ms)
Wait for some milliseconds from a time reference.
void port_system_gpio_config_alternate(GPIO_TypeDef *p_port, uint8_t pin, uint8_t alternate)
Configure the alternate function of a GPIO.
size_t port_system_init(void)
This function is based on the initialization of the HAL Library; it must be the first thing to be exe...