|
#include <stdbool.h>
#include <stddef.h>
#include "main.h"
#include "acc_integration.h"
#include "acc_reg_protocol.h"
#include "i2c_application_system.h"
Go to the source code of this file.
Data Structures | |
struct | gpio_config_t |
GPIO config status, maps directly to the GPIO registers. More... | |
Macros | |
#define | I2C_SLAVE_BUFFER_SIZE 4 |
#define | WAIT_FOR_IDLE_RETRIES 10U |
#define | WAIT_FOR_IDLE_RETRY_INTERNAL_MS 10U |
#define | GPIO_BANK_COUNT 3U |
Functions | |
static void | disable_interrupts (void) |
Disable interrupts. More... | |
static void | enable_interrupts (void) |
Enable interrupts. More... | |
static void | prepare_power_down (void) |
Prepare power down state. More... | |
static void | resume_power_down (void) |
Resume power down state. More... | |
static uint32_t | get_rtc_tick (void) |
Get RTC ticks based on current RTC time. More... | |
static void | rtc_tick_to_time (uint32_t tick, RTC_TimeTypeDef *time) |
Convert RTC ticks to RTC time. More... | |
static void | rtc_set_next_wakeup_time (void) |
Function for setting the next wakeup time from the RTC interrupt. More... | |
static void | wait_for_i2c_idle (void) |
Wait for I2C interface to be idle. More... | |
static void | prepare_register_data (I2C_HandleTypeDef *hi2c) |
Helper function to prepare transmit of register data. More... | |
void | i2c_application_system_init (void) |
Init the system. More... | |
void | i2c_application_system_reset (void) |
Reset the system. More... | |
void | i2c_application_system_wait_for_interrupt (void) |
Wait for interrupt to occur. More... | |
bool | i2c_application_system_test_wakeup_pin (void) |
Check if wakeup pin is high. More... | |
void | i2c_application_system_set_ready_pin (bool enable) |
Set the ready pin state. More... | |
void | i2c_application_system_setup_generic_gpio_pin (bool enable) |
Setup the generic gpio pin. More... | |
void | i2c_application_system_set_generic_gpio_pin (bool enable) |
Set the generic gpio pin output state. More... | |
void | i2c_application_enter_low_power_state (void) |
Make the MCU enter its low power state. More... | |
void | i2c_application_set_periodic_wakeup (uint32_t period_ms) |
Set up a periodic timer used to wake up the system from sleep. More... | |
bool | i2c_application_is_periodic_wakeup (void) |
Test if a periodic wake up has occurred. More... | |
void | HAL_RTCEx_AlarmBEventCallback (RTC_HandleTypeDef *rtc) |
IRQ Handler for RTC B Alarm. More... | |
void | HAL_I2C_AddrCallback (I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode) |
void | HAL_I2C_SlaveTxCpltCallback (I2C_HandleTypeDef *hi2c) |
void | HAL_I2C_SlaveRxCpltCallback (I2C_HandleTypeDef *hi2c) |
void | HAL_I2C_ListenCpltCallback (I2C_HandleTypeDef *hi2c) |
void | HAL_I2C_ErrorCallback (I2C_HandleTypeDef *hi2c) |
Variables | |
SPI_HandleTypeDef | A121_SPI_HANDLE |
I2C_HandleTypeDef | MODULE_I2C_HANDLE |
UART_HandleTypeDef | MODULE_UART1_HANDLE |
UART_HandleTypeDef | MODULE_UART2_HANDLE |
RTC_HandleTypeDef | MODULE_RTC_HANDLE |
static RCC_OscInitTypeDef | low_power_saved_rcc_oscinitstruct |
static RCC_ClkInitTypeDef | low_power_saved_rcc_clkinitstruct |
static uint32_t | low_power_saved_flatency |
static gpio_config_t | low_power_saved_gpio_bank [3U] = { 0 } |
static GPIO_TypeDef * | gpio_banks [3U] = { GPIOA, GPIOB, GPIOH } |
static uint8_t | i2c_slave_buffer [4] |
static volatile bool | i2c_idle = true |
static uint32_t | rtc_period_time_ms = 0 |
static volatile bool | rtc_wakeup_triggered = false |
#define GPIO_BANK_COUNT 3U |
Definition at line 19 of file i2c_application_system_stm32.c.
#define I2C_SLAVE_BUFFER_SIZE 4 |
Definition at line 16 of file i2c_application_system_stm32.c.
#define WAIT_FOR_IDLE_RETRIES 10U |
Definition at line 17 of file i2c_application_system_stm32.c.
#define WAIT_FOR_IDLE_RETRY_INTERNAL_MS 10U |
Definition at line 18 of file i2c_application_system_stm32.c.
|
inlinestatic |
Disable interrupts.
Definition at line 245 of file i2c_application_system_stm32.c.
|
inlinestatic |
Enable interrupts.
Definition at line 253 of file i2c_application_system_stm32.c.
|
static |
Get RTC ticks based on current RTC time.
Definition at line 354 of file i2c_application_system_stm32.c.
void HAL_I2C_AddrCallback | ( | I2C_HandleTypeDef * | hi2c, |
uint8_t | TransferDirection, | ||
uint16_t | AddrMatchCode | ||
) |
Calling this function with wrong parameters will return HAL_ERROR Calling this function when the i2c module is in the wrong state return HAL_BUSY
Definition at line 497 of file i2c_application_system_stm32.c.
void HAL_I2C_ErrorCallback | ( | I2C_HandleTypeDef * | hi2c | ) |
The data NACK is the only valid error code
Definition at line 590 of file i2c_application_system_stm32.c.
void HAL_I2C_ListenCpltCallback | ( | I2C_HandleTypeDef * | hi2c | ) |
Calling this function with wrong parameters will return HAL_ERROR Calling this function when the i2c module is in the wrong state return HAL_BUSY
Definition at line 574 of file i2c_application_system_stm32.c.
void HAL_I2C_SlaveRxCpltCallback | ( | I2C_HandleTypeDef * | hi2c | ) |
Calling this function with wrong parameters will return HAL_ERROR Calling this function when the i2c module is in the wrong state return HAL_BUSY
Definition at line 537 of file i2c_application_system_stm32.c.
void HAL_I2C_SlaveTxCpltCallback | ( | I2C_HandleTypeDef * | hi2c | ) |
Definition at line 530 of file i2c_application_system_stm32.c.
void HAL_RTCEx_AlarmBEventCallback | ( | RTC_HandleTypeDef * | rtc | ) |
IRQ Handler for RTC B Alarm.
Definition at line 237 of file i2c_application_system_stm32.c.
void i2c_application_enter_low_power_state | ( | void | ) |
Make the MCU enter its low power state.
This function is called by the i2c application when the MCU should power down.
Wait for the i2c interface to be idle, if not idle after retries, power down anyway!
Definition at line 192 of file i2c_application_system_stm32.c.
bool i2c_application_is_periodic_wakeup | ( | void | ) |
Test if a periodic wake up has occurred.
Definition at line 223 of file i2c_application_system_stm32.c.
void i2c_application_set_periodic_wakeup | ( | uint32_t | period_ms | ) |
Set up a periodic timer used to wake up the system from sleep.
If the time_msec is set to zero the periodic wakeup will be disabled.
period_ms | Period time in milliseconds |
Definition at line 216 of file i2c_application_system_stm32.c.
void i2c_application_system_init | ( | void | ) |
Init the system.
This function is called by the i2c application during initialization.
Calling this function with wrong parameters will return HAL_ERROR Calling this function when the i2c module is in the wrong state return HAL_BUSY
Definition at line 110 of file i2c_application_system_stm32.c.
void i2c_application_system_reset | ( | void | ) |
Reset the system.
This function is called by the i2c application when the system should be restarted.
Wait for the i2c interface to be idle, if not idle after retries, reset anyway!
Definition at line 129 of file i2c_application_system_stm32.c.
void i2c_application_system_set_generic_gpio_pin | ( | bool | enable | ) |
Set the generic gpio pin output state.
This function is used to set the output state of the generic gpio pin
[in] | enable | pin output is set to high level when enable is true |
Definition at line 184 of file i2c_application_system_stm32.c.
void i2c_application_system_set_ready_pin | ( | bool | enable | ) |
Set the ready pin state.
This function is used to set the state of the ready pin
[in] | enable | pin is set to high level when enable is true |
Definition at line 155 of file i2c_application_system_stm32.c.
void i2c_application_system_setup_generic_gpio_pin | ( | bool | enable | ) |
Setup the generic gpio pin.
This function is used to setup the generic gpio pin
[in] | enable | pin is set to output driver when enable is true |
Definition at line 163 of file i2c_application_system_stm32.c.
bool i2c_application_system_test_wakeup_pin | ( | void | ) |
Check if wakeup pin is high.
This function is used to test if the system should power down
Definition at line 147 of file i2c_application_system_stm32.c.
void i2c_application_system_wait_for_interrupt | ( | void | ) |
Wait for interrupt to occur.
Definition at line 141 of file i2c_application_system_stm32.c.
|
inlinestatic |
Prepare power down state.
Definition at line 261 of file i2c_application_system_stm32.c.
|
static |
Helper function to prepare transmit of register data.
[in] | hi2c | The I2C handle |
Calling this function with wrong parameters will return HAL_ERROR Calling this function when the i2c module is in the wrong state return HAL_BUSY
Definition at line 472 of file i2c_application_system_stm32.c.
|
inlinestatic |
Resume power down state.
Calling this function with wrong parameters will return HAL_ERROR Calling this function when the i2c module is in the wrong state return HAL_BUSY
Definition at line 313 of file i2c_application_system_stm32.c.
|
static |
Function for setting the next wakeup time from the RTC interrupt.
Definition at line 420 of file i2c_application_system_stm32.c.
|
static |
Convert RTC ticks to RTC time.
[in] | tick | rtc ticks in ms |
[out] | time | RTC time |
Definition at line 398 of file i2c_application_system_stm32.c.
|
static |
Wait for I2C interface to be idle.
Definition at line 452 of file i2c_application_system_stm32.c.
SPI_HandleTypeDef A121_SPI_HANDLE |
|
static |
Definition at line 41 of file i2c_application_system_stm32.c.
|
static |
Definition at line 44 of file i2c_application_system_stm32.c.
|
static |
Definition at line 43 of file i2c_application_system_stm32.c.
|
static |
Definition at line 39 of file i2c_application_system_stm32.c.
|
static |
Definition at line 40 of file i2c_application_system_stm32.c.
|
static |
Definition at line 38 of file i2c_application_system_stm32.c.
|
static |
Definition at line 37 of file i2c_application_system_stm32.c.
I2C_HandleTypeDef MODULE_I2C_HANDLE |
RTC_HandleTypeDef MODULE_RTC_HANDLE |
UART_HandleTypeDef MODULE_UART1_HANDLE |
UART_HandleTypeDef MODULE_UART2_HANDLE |
|
static |
Definition at line 46 of file i2c_application_system_stm32.c.
|
static |
Definition at line 47 of file i2c_application_system_stm32.c.