121 lines
3.3 KiB
C
121 lines
3.3 KiB
C
/*
|
|
* utils.h
|
|
*
|
|
* Created on: 22-Jan-2024
|
|
* Author: saar
|
|
*/
|
|
|
|
#ifndef UTILS_UTILS_H_
|
|
#define UTILS_UTILS_H_
|
|
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include "ti_msp_dl_config.h"
|
|
//#define GPIO 0
|
|
//#define UART 0
|
|
|
|
typedef enum
|
|
{
|
|
/* Generic error codes */
|
|
IVEC_MCAL_STATUS_INIT_FAIL = -1,
|
|
IVEC_MCAL_STATUS_SUCCESS , /*!< Generic operation success status */
|
|
IVEC_MCAL_STATUS_ERROR , /*!< Generic operation failure status */
|
|
IVEC_MCAL_STATUS_BUSY , /*!< Generic operation busy status */
|
|
IVEC_MCAL_STATUS_TIMEOUT , /*!< Generic operation timeout status */
|
|
IVEC_MCAL_STATUS_UNSUPPORTED , /*!< Generic operation unsupported status */
|
|
IVEC_MCAL_STATUS_TRUE , /*!< Generic operation true status */
|
|
IVEC_MCAL_STATUS_FALSE , /*!< Generic operation false status */
|
|
}IVEC_McalStatus_e;
|
|
|
|
#define GPIO 5
|
|
#define UART 1
|
|
#define HFXT 2
|
|
#define STANDBY0 3
|
|
#define SYSOSC 4
|
|
#define SLEEP0 6
|
|
|
|
// UART_PIN_SELECTION values:
|
|
// 1 - Basil Battery Smart
|
|
// 2 - Basil
|
|
// 3 - Battery Swapping Station
|
|
#define UART_PIN_SELECTION 3 // Set the desired UART configuration here
|
|
|
|
|
|
volatile int i32TickCnt;
|
|
|
|
|
|
typedef enum
|
|
{
|
|
/* Generic error codes */
|
|
STATUS_INIT_FAIL = 1,
|
|
STATUS_SUCCESS = 0, /*!< Generic operation success status */
|
|
STATUS_ERROR = -1, /*!< Generic operation failure status */
|
|
STATUS_BUSY = 2, /*!< Generic operation busy status */
|
|
STATUS_TIMEOUT = 3, /*!< Generic operation timeout status */
|
|
STATUS_UNSUPPORTED = 4, /*!< Generic operation unsupported status */
|
|
}xCoreStatus_t;
|
|
|
|
typedef enum
|
|
{
|
|
/*UART Baud Rate Options*/
|
|
BAUD_115200 = 0,
|
|
BAUD_9600 = 1,
|
|
}xUart_baud_t;
|
|
|
|
typedef enum
|
|
{
|
|
/*CAN Baud Rate Options*/
|
|
BAUD_500 = 500,
|
|
BAUD_250 = 250,
|
|
BAUD_150 = 150,
|
|
BAUD_1000 = 1000,
|
|
BAUD_125 = 125,
|
|
|
|
}xCAN_baud_t;
|
|
|
|
typedef enum
|
|
{
|
|
/*SPI Clock Speed Options*/
|
|
CS_1Mhz = 0,
|
|
}xSPI_CS_t;
|
|
|
|
typedef enum
|
|
{
|
|
/*SysTick Period Options*/
|
|
Period_1ms = 72000, /*!< sets period of SysTick to 1ms @48Mhz*/
|
|
}xTicks_t;
|
|
|
|
typedef enum
|
|
{
|
|
/*SPI Clock Speed Options*/
|
|
BAUD_100Khz = 0,
|
|
BAUD_400Khz,
|
|
}xI2C_baud_t;
|
|
|
|
typedef enum {
|
|
I2C_STATUS_IDLE = 0,
|
|
I2C_STATUS_TX_STARTED,
|
|
I2C_STATUS_TX_INPROGRESS,
|
|
I2C_STATUS_TX_COMPLETE,
|
|
I2C_STATUS_RX_STARTED,
|
|
I2C_STATUS_RX_INPROGRESS,
|
|
I2C_STATUS_RX_COMPLETE,
|
|
I2C_STATUS_ERROR,
|
|
} xI2cControllerStatus_t;
|
|
|
|
void mcuInit(void);
|
|
xCoreStatus_t xMCAL_SYSCTL_INIT(uint8_t u8CLK_SRC,uint8_t u8LP_MODE);
|
|
xCoreStatus_t xMCAL_SYSTICK_INIT(xTicks_t tick);
|
|
//void delay (uint32_t us);
|
|
int i32MCAL_getTicks();
|
|
void vMCAL_DelayTicks(int i32Delay_ms);
|
|
|
|
void xMCAL_SoftReset(void);
|
|
void xMCAL_McuInit(void);
|
|
void delay (uint32_t us);
|
|
IVEC_McalStatus_e xMCAL_VrefInit(void);
|
|
|
|
|
|
|
|
#endif /* UTILS_UTILS_H_ */
|