This repository has been archived on 2024-05-28. You can view files and clone it, but cannot push or open issues or pull requests.
stm32u5_cargo/stm32u5/includes/global_variable.h
2023-11-14 16:25:09 -05:00

66 lines
2.5 KiB
C
Executable File

//
// Created by zong on 2/3/23.
//
// this file will contain some global variable,
// when use modify and use this variable should be very careful.
// All places change these variables should add comment in this file.
#ifndef STM32U5_GLOBAL_VARIABLE_H
#define STM32U5_GLOBAL_VARIABLE_H
#define __WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#define __UNUSED __attribute__((unused))
// #define IF_ERROR_RETURN(x) if (x != HAL_OK) return x
#define IF_ERROR_STUCK(x) \
if (x != HAL_OK) \
while (1) {}
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
extern uint32_t system_core_clock;
extern uint32_t system_core_clock_mhz;
extern uint32_t rtc_clock;
void update_system_clock(uint32_t system_clock);
void update_hclk(uint32_t hclk);
typedef enum {
HAL_OK = 0, // ok
HAL_TIMEOUT, // timeout (failed when wait for something)
QUEUE_EMPTY, // the queue is empty
QUEUE_ERROR_REINIT, // the queue is already init_old
QUEUE_ERROR_NO_ENOUGH_SPACE, // not enough space to push data
QUEUE_ERROR_NULL_DATA_POINTER, // the data pointer is NULL
QUEUE_ERROR_NO_LINE, // no line in the queue
QUEUE_ERROR_BUFFER_OVERFLOW, // the user data buffer is not enough to store the data
QUEUE_ERROR_NO_ENOUGH_DATA, // the queue data is not enough to read
QUEUE_ERROR_MALLOC_FAILED, // malloc failed when init_old the queue
GPIO_ERROR_REINIT, // gpio init more than once
I2C_BUSY, // i2c bus error
I2C_GPIO_INIT_ERROR, // i2c port init_old error
I2C_QUEUE_ERROR, // i2c queue error
I2C_TIMEOUT, // i2c timeout
I2C_ERROR, // i2c error
DMA_STATUS_REINIT, // dma reinit
DMA_STATUS_MALLOC_FAILED, // dam allocate link list space failed
DMA_STATUS_INVALID_SIZE, // dma transfer size error.
DMA_STATUS_NOT_ENABLED, // dma not enable
SDMMC_BUSY, // sdmmc busy
SDMMC_ERROR, // sdmmc error
SDMMC_CMD23_NOT_SUPPORT, // sd card not support cmd23 not support
HAL_ERROR
} hal_status_e;
typedef enum {
LL_DISABLE = 0, // disable for peripheral bit
LL_ENABLE = 1, // enable for peripheral bit
} ll_state_e;
#define ll_high LL_ENABLE
#define ll_low LL_DISABLE
#endif // STM32U5_GLOBAL_VARIABLE_H