3个wf5803测量可以
This commit is contained in:
parent
8406f3d631
commit
486c9f875b
360
APP/bsp_wf5803.c
360
APP/bsp_wf5803.c
|
@ -1,68 +1,96 @@
|
|||
#include "bsp_wf5803.h"
|
||||
#include "CONFIG.h"
|
||||
|
||||
static tmosTaskID wf5803_task_id = INVALID_TASK_ID;
|
||||
|
||||
#define WF5803_CSB4_HIGH() GPIOB_SetBits(GPIO_Pin_17)
|
||||
#define WF5803_CSB4_LOW() GPIOB_ResetBits(GPIO_Pin_17)
|
||||
|
||||
#define WF5803_CSB4_HIGH() GPIOB_SetBits(GPIO_Pin_17)
|
||||
#define WF5803_CSB4_LOW() GPIOB_ResetBits(GPIO_Pin_17)
|
||||
|
||||
#define WF5803_CSB4_HIGH() GPIOB_SetBits(GPIO_Pin_17)
|
||||
#define WF5803_CSB4_LOW() GPIOB_ResetBits(GPIO_Pin_17)
|
||||
|
||||
uint8_t volatile vcc4_state = 0;
|
||||
|
||||
|
||||
void SPICs_Start(void)
|
||||
typedef enum
|
||||
{
|
||||
// GPIOA_ResetBits(GPIO_Pin_6);
|
||||
WF5803_CSB4_LOW();
|
||||
kPressIn = 0,
|
||||
kPressOut = 1,
|
||||
kPressAtom = 2,
|
||||
kPressMaxIndex
|
||||
} TePressSensorIndex;
|
||||
|
||||
static tmosTaskID press_task_id = INVALID_TASK_ID;
|
||||
|
||||
#define PRESS_IN_CS_HIGH() GPIOB_SetBits(GPIO_Pin_9)
|
||||
#define PRESS_IN_CS_LOW() GPIOB_ResetBits(GPIO_Pin_9)
|
||||
|
||||
#define PRESS_OUT_CS_HIGH() GPIOB_SetBits(GPIO_Pin_4)
|
||||
#define PRESS_OUT_CS_LOW() GPIOB_ResetBits(GPIO_Pin_4)
|
||||
|
||||
#define PRESS_ATOM_CS_HIGH() GPIOB_SetBits(GPIO_Pin_17)
|
||||
#define PRESS_ATOM_CS_LOW() GPIOB_ResetBits(GPIO_Pin_17)
|
||||
|
||||
uint8_t volatile press_done_flag = 0;
|
||||
|
||||
uint8_t press_raw_data[kPressMaxIndex][5];
|
||||
|
||||
void PRESS_SPI_CsStart(TePressSensorIndex index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case kPressIn:
|
||||
PRESS_IN_CS_LOW();
|
||||
break;
|
||||
case kPressOut:
|
||||
PRESS_OUT_CS_LOW();
|
||||
break;
|
||||
case kPressAtom:
|
||||
PRESS_ATOM_CS_LOW();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SPICs_Stop(void)
|
||||
void PRESS_SPI_CsStop(TePressSensorIndex index)
|
||||
{
|
||||
// GPIOA_SetBits(GPIO_Pin_6);
|
||||
WF5803_CSB4_HIGH();
|
||||
switch (index)
|
||||
{
|
||||
case kPressIn:
|
||||
PRESS_IN_CS_HIGH();
|
||||
break;
|
||||
case kPressOut:
|
||||
PRESS_OUT_CS_HIGH();
|
||||
break;
|
||||
case kPressAtom:
|
||||
PRESS_ATOM_CS_HIGH();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t WF5803_SendByte(uint8_t data)
|
||||
uint8_t PRESS_SPI_SendByte(uint8_t data)
|
||||
{
|
||||
R8_SPI0_BUFFER = data;
|
||||
while (!(R8_SPI0_INT_FLAG & RB_SPI_FREE));
|
||||
return (R8_SPI0_BUFFER);
|
||||
}
|
||||
|
||||
void WF5803_WriteReg(uint8_t Address, uint8_t value)
|
||||
void WF5803_WriteReg(uint8_t Address, uint8_t value, TePressSensorIndex index)
|
||||
{
|
||||
SPICs_Start();
|
||||
WF5803_SendByte(0x00);
|
||||
WF5803_SendByte(Address);
|
||||
WF5803_SendByte(value);
|
||||
SPICs_Stop();
|
||||
PRESS_SPI_CsStart(index);
|
||||
PRESS_SPI_SendByte(0x00);
|
||||
PRESS_SPI_SendByte(Address);
|
||||
PRESS_SPI_SendByte(value);
|
||||
PRESS_SPI_CsStop(index);
|
||||
}
|
||||
|
||||
uint8_t WF5803_ReadReg(uint8_t addr)
|
||||
uint8_t WF5803_ReadReg(uint8_t addr, TePressSensorIndex index)
|
||||
{
|
||||
uint8_t value;
|
||||
SPICs_Start();
|
||||
WF5803_SendByte(0x80);
|
||||
WF5803_SendByte(addr);
|
||||
value = WF5803_SendByte(0xFF);
|
||||
SPICs_Stop();
|
||||
PRESS_SPI_CsStart(index);
|
||||
PRESS_SPI_SendByte(0x80);
|
||||
PRESS_SPI_SendByte(addr);
|
||||
value = PRESS_SPI_SendByte(0xFF);
|
||||
PRESS_SPI_CsStop(index);
|
||||
return value;
|
||||
}
|
||||
|
||||
void WF5803_Init(void)
|
||||
void PRESS_IO_SPI_Init(void)
|
||||
{
|
||||
/**
|
||||
* CSB: PA6
|
||||
* SCL: PA0
|
||||
* SDA: PA1
|
||||
* SDO: PA2
|
||||
*/
|
||||
|
||||
/**
|
||||
* CSB: PB17
|
||||
* SCL: PA13
|
||||
|
@ -71,83 +99,42 @@ void WF5803_Init(void)
|
|||
*/
|
||||
// SDA: MOSI
|
||||
// SDO: MISO
|
||||
#if 1
|
||||
// VCC1: PA2
|
||||
// GPIOA_SetBits(GPIO_Pin_2);
|
||||
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeOut_PP_20mA);
|
||||
// GPIOA_SetBits(GPIO_Pin_2);
|
||||
|
||||
// // CSB1: PA3
|
||||
// GPIOA_SetBits(GPIO_Pin_3);
|
||||
// GPIOA_ModeCfg(GPIO_Pin_3, GPIO_ModeOut_PP_5mA);
|
||||
// GPIOA_SetBits(GPIO_Pin_3);
|
||||
|
||||
// // VCC2: PB8
|
||||
// GPIOB_SetBits(GPIO_Pin_8);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_8, GPIO_ModeOut_PP_5mA);
|
||||
// GPIOB_SetBits(GPIO_Pin_8);
|
||||
|
||||
// CSB2: PB9
|
||||
GPIOB_SetBits(GPIO_Pin_9);
|
||||
GPIOB_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA);
|
||||
GPIOB_SetBits(GPIO_Pin_9);
|
||||
|
||||
// // VCC3: PB3
|
||||
// GPIOB_SetBits(GPIO_Pin_3);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_3, GPIO_ModeOut_PP_5mA);
|
||||
// GPIOB_SetBits(GPIO_Pin_3);
|
||||
|
||||
// CSB3: PB4
|
||||
GPIOB_SetBits(GPIO_Pin_4);
|
||||
GPIOB_ModeCfg(GPIO_Pin_4, GPIO_ModeOut_PP_5mA);
|
||||
GPIOB_SetBits(GPIO_Pin_4);
|
||||
|
||||
// // VCC4: PB16
|
||||
// GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_PU);
|
||||
// // GPIOB_SetBits(GPIO_Pin_17);
|
||||
// mDelayuS(5);
|
||||
|
||||
|
||||
|
||||
// CSB4: PB17
|
||||
GPIOB_SetBits(GPIO_Pin_17);
|
||||
GPIOB_ModeCfg(GPIO_Pin_17, GPIO_ModeOut_PP_5mA);
|
||||
GPIOB_SetBits(GPIO_Pin_17);
|
||||
|
||||
PRESS_SPI_CsStop(kPressIn);
|
||||
PRESS_SPI_CsStop(kPressOut);
|
||||
PRESS_SPI_CsStop(kPressAtom);
|
||||
|
||||
// spi初始化,模式0
|
||||
GPIOA_ModeCfg(GPIO_Pin_13 | GPIO_Pin_14, GPIO_ModeOut_PP_5mA);
|
||||
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PU);
|
||||
#endif
|
||||
// PRINT("GPIOA_ModeCfg ok\r\n");
|
||||
|
||||
SPI0_MasterDefInit();
|
||||
// PRINT("SPI1_MasterDefInit ok\r\n");
|
||||
|
||||
SPICs_Stop();
|
||||
// PRINT("SPICs_Stop ok\r\n");
|
||||
WF5803_WriteReg(0x00, 0x81); // 配置spi为四线模式
|
||||
// PRINT("WF5803_WriteReg ok\r\n");
|
||||
|
||||
// PRINT("SPI_Init ok\r\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WF5803_DeInit(void)
|
||||
void WF5803_Init(void)
|
||||
{
|
||||
PRESS_IO_SPI_Init();
|
||||
WF5803_WriteReg(0x00, 0x81, kPressIn); // 配置spi为四线模式
|
||||
WF5803_WriteReg(0x00, 0x81, kPressOut); // 配置spi为四线模式
|
||||
WF5803_WriteReg(0x00, 0x81, kPressAtom); // 配置spi为四线模式
|
||||
}
|
||||
|
||||
void PRESS_LowerIO_Init(void)
|
||||
{
|
||||
// WF5803默认供电时,其他IO都是高电平
|
||||
// SPI
|
||||
// if (vcc4_state == 1)
|
||||
// {
|
||||
// GPIOA_ResetBits(GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
|
||||
// GPIOA_ModeCfg(GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15, GPIO_ModeIN_PU);
|
||||
|
||||
// // CSB4: PB11
|
||||
// GPIOB_ResetBits(GPIO_Pin_17);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_17, GPIO_ModeIN_PU);
|
||||
// }
|
||||
// else
|
||||
if (vcc4_state == 0)
|
||||
{
|
||||
GPIOA_SetBits(GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
|
||||
GPIOA_ModeCfg(GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15, GPIO_ModeIN_PU);
|
||||
|
||||
|
@ -159,57 +146,13 @@ void WF5803_DeInit(void)
|
|||
GPIOB_SetBits(GPIO_Pin_4);
|
||||
GPIOB_ModeCfg(GPIO_Pin_4, GPIO_ModeIN_PU);
|
||||
|
||||
// CSB4: PB17
|
||||
GPIOB_SetBits(GPIO_Pin_17);
|
||||
GPIOB_ModeCfg(GPIO_Pin_17, GPIO_ModeIN_PU);
|
||||
}
|
||||
|
||||
// // VCC1: PA2
|
||||
// GPIOA_ResetBits(GPIO_Pin_2);
|
||||
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_PD);
|
||||
|
||||
// CSB1: PA3
|
||||
// GPIOA_ResetBits(GPIO_Pin_3);
|
||||
// GPIOA_ModeCfg(GPIO_Pin_3, GPIO_ModeIN_PD);
|
||||
|
||||
// GPIOA_SetBits(GPIO_Pin_3);
|
||||
// GPIOA_ModeCfg(GPIO_Pin_3, GPIO_ModeIN_PU);
|
||||
|
||||
// // VCC2: PB8
|
||||
// GPIOB_ResetBits(GPIO_Pin_8);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_8, GPIO_ModeIN_PD);
|
||||
|
||||
// // CSB2: PB9
|
||||
// GPIOB_ResetBits(GPIO_Pin_9);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_9, GPIO_ModeIN_PD);
|
||||
|
||||
|
||||
// // VCC3: PB3
|
||||
// GPIOB_ResetBits(GPIO_Pin_3);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_3, GPIO_ModeIN_PD);
|
||||
|
||||
// CSB3: PB4
|
||||
// GPIOB_ResetBits(GPIO_Pin_4);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_4, GPIO_ModeIN_PD);
|
||||
// GPIOB_SetBits(GPIO_Pin_4);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_4, GPIO_ModeIN_PU);
|
||||
|
||||
// if (vcc4_state == 1)
|
||||
// {
|
||||
// // VCC4: PB16
|
||||
// // GPIOB_SetBits(GPIO_Pin_16);
|
||||
// // GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeOut_PP_5mA);
|
||||
// // GPIOB_SetBits(GPIO_Pin_16);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // VCC4: PB16
|
||||
// GPIOB_ResetBits(GPIO_Pin_16);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_PD);
|
||||
// PRINT("vcc4_state = 0\r\n");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
void Lower_IO_Deinit(void)
|
||||
{
|
||||
// LED
|
||||
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12);
|
||||
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12, GPIO_ModeIN_PD);
|
||||
|
@ -231,52 +174,45 @@ void WF5803_DeInit(void)
|
|||
GPIOA_ModeCfg(GPIO_Pin_0 | GPIO_Pin_1, GPIO_ModeIN_PD);
|
||||
}
|
||||
|
||||
long reading = 0;
|
||||
float press = 0;
|
||||
float temp = 0;
|
||||
float fDat = 0;
|
||||
float press_air = 101.0f;
|
||||
int a = 1;
|
||||
uint8_t RawData[5];
|
||||
|
||||
uint8_t *GetSensorData(void)
|
||||
void PRESS_LowPower(void)
|
||||
{
|
||||
memset(RawData, 0, sizeof(uint8_t) * 5);
|
||||
// WF5803_WriteReg(0x30, 0x0a);
|
||||
// DelayMs(50);
|
||||
Lower_IO_Deinit();
|
||||
if (press_done_flag == 1)
|
||||
{
|
||||
PRESS_LowerIO_Init();
|
||||
}
|
||||
}
|
||||
|
||||
PRINT("DRDTY = %02x\r\n", WF5803_ReadReg(0x02));
|
||||
uint8_t GetSensorData(TePressSensorIndex index)
|
||||
{
|
||||
memset(press_raw_data[index], 0, 5);
|
||||
|
||||
PRINT("Status = %02x\r\n", WF5803_ReadReg(0x02, index));
|
||||
|
||||
// 气压数据
|
||||
|
||||
RawData[0] = WF5803_ReadReg(0x06);
|
||||
RawData[1] = WF5803_ReadReg(0x07);
|
||||
RawData[2] = WF5803_ReadReg(0x08);
|
||||
// 温度数据
|
||||
RawData[3] = WF5803_ReadReg(0x09);
|
||||
RawData[4] = WF5803_ReadReg(0x0a);
|
||||
|
||||
// for(int i=0; i<5; i++)
|
||||
// {
|
||||
// PRINT("RawData[%d] = %x\r\n", i,RawData[i]);
|
||||
// }
|
||||
return RawData;
|
||||
for (uint8_t i = 0; i < 5; i++)
|
||||
{
|
||||
press_raw_data[index][i] = WF5803_ReadReg(0x06 + i, index);
|
||||
}
|
||||
|
||||
void WF5803_Start(void)
|
||||
{
|
||||
WF5803_WriteReg(0x21, 0x47); // 开启气压和温度传感器
|
||||
WF5803_WriteReg(0x27, 0x41); // 开启气压和温度传感器
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SensorData_Process(void)
|
||||
void SensorData_Process(TePressSensorIndex index)
|
||||
{
|
||||
uint8_t *p1 = GetSensorData();
|
||||
reading = p1[0];
|
||||
long reading = 0;
|
||||
float fDat = 0;
|
||||
float press = 0;
|
||||
float temp = 0;
|
||||
|
||||
GetSensorData(index);
|
||||
|
||||
reading = press_raw_data[index][0];
|
||||
reading = reading << 8;
|
||||
reading |= p1[1];
|
||||
reading |= press_raw_data[index][1];
|
||||
reading = reading << 8;
|
||||
reading |= p1[2];
|
||||
reading |= press_raw_data[index][2];
|
||||
if (reading >= 8388608)
|
||||
{
|
||||
fDat = (int32_t)(reading - 16777216) / 8388608.0f;
|
||||
|
@ -288,16 +224,9 @@ void SensorData_Process(void)
|
|||
|
||||
press = fDat * 125 + 17.5; // WF5803_1BAR 如果是使用10m级别的深传就使用这个
|
||||
|
||||
// if (a) {press_air = press ; a = 0;}
|
||||
// press = press_air > press ? press_air : press;
|
||||
//
|
||||
// int deep_100 = (int)(100*((press - press_air)/0.098f));
|
||||
// //printf("P=%d.%d pa\r\n",(int)press,((int)(press*10000.0f)%10000));`
|
||||
// printf("D=%d.%d cm\r\n",deep_100/100,deep_100%100);
|
||||
|
||||
reading = p1[3];
|
||||
reading = press_raw_data[index][3];
|
||||
reading = reading << 8;
|
||||
reading |= p1[4];
|
||||
reading |= press_raw_data[index][4];
|
||||
if (reading > 32768)
|
||||
{
|
||||
temp = (reading - 65844) / 256.0f;
|
||||
|
@ -306,69 +235,44 @@ void SensorData_Process(void)
|
|||
{
|
||||
temp = (reading - 308) / 256.0f;
|
||||
}
|
||||
// PRINT("--s-1--\r\n");
|
||||
PRINT("P=%d.%d pa\r\n", (int)(press * 1000), ((int)(press * 10000000.0f) % 10000));
|
||||
PRINT("T=%d.%d \r\n", (int)temp, ((int)(temp * 100.0f) % 100));
|
||||
|
||||
PRINT("P[%d] = %d.%d pa\r\n", index, (int)(press * 1000), ((int)(press * 10000000.0f) % 10000));
|
||||
PRINT("T[%d] = %d.%d \r\n", index, (int)temp, ((int)(temp * 100.0f) % 100));
|
||||
}
|
||||
|
||||
// __HIGH_CODE
|
||||
// __attribute__((noinline))
|
||||
uint16_t WF5803_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||
{
|
||||
if (events & WF5803_EVT_VCC)
|
||||
if (events & WF5803_EVT_START)
|
||||
{
|
||||
if (vcc4_state == 0)
|
||||
{
|
||||
vcc4_state = 1;
|
||||
// GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_PU);
|
||||
|
||||
// mDelaymS(20);
|
||||
// GPIOB_SetBits(GPIO_Pin_16);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeOut_PP_5mA);
|
||||
// GPIOB_SetBits(GPIO_Pin_16);
|
||||
|
||||
PRINT("WF5803_EVT_VCC\r\n");
|
||||
}
|
||||
tmos_start_task(wf5803_task_id, WF5803_EVT_START, MS1_TO_SYSTEM_TIME(20));
|
||||
|
||||
return (events ^ WF5803_EVT_VCC);
|
||||
}
|
||||
else if (events & WF5803_EVT_START)
|
||||
{
|
||||
// SensorData_Process();
|
||||
// WF5803_WriteReg(0x30, 0x0a);
|
||||
|
||||
vcc4_state = 1;
|
||||
press_done_flag = 0;
|
||||
|
||||
WF5803_Init();
|
||||
|
||||
WF5803_WriteReg(0x30, 0x0A);
|
||||
WF5803_WriteReg(0x30, 0x0A, kPressIn);
|
||||
WF5803_WriteReg(0x30, 0x0A, kPressOut);
|
||||
WF5803_WriteReg(0x30, 0x0A, kPressAtom);
|
||||
|
||||
tmos_start_task(wf5803_task_id, WF5803_EVT_READ, MS1_TO_SYSTEM_TIME(5));
|
||||
tmos_start_task(press_task_id, WF5803_EVT_READ, MS1_TO_SYSTEM_TIME(5));
|
||||
return (events ^ WF5803_EVT_START);
|
||||
}
|
||||
else if (events & WF5803_EVT_READ)
|
||||
{
|
||||
SensorData_Process();
|
||||
// WF5803_WriteReg(0x30, 0x0a);
|
||||
SensorData_Process(kPressIn);
|
||||
SensorData_Process(kPressOut);
|
||||
SensorData_Process(kPressAtom);
|
||||
|
||||
tmos_start_task(wf5803_task_id, WF5803_EVT_START, MS1_TO_SYSTEM_TIME(800));
|
||||
tmos_start_task(press_task_id, WF5803_EVT_START, MS1_TO_SYSTEM_TIME(800));
|
||||
|
||||
// GPIOB_ResetBits(GPIO_Pin_16);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_PD);
|
||||
// PRINT("vcc4_state = 0\r\n");
|
||||
|
||||
vcc4_state = 0;
|
||||
press_done_flag = 1;
|
||||
return (events ^ WF5803_EVT_READ);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BSPWF5803_Init(void)
|
||||
void BSP_PRESS_Init(void)
|
||||
{
|
||||
// WF5803_Init();
|
||||
wf5803_task_id = TMOS_ProcessEventRegister(WF5803_ProcessEvent);
|
||||
|
||||
tmos_set_event(wf5803_task_id, WF5803_EVT_START);
|
||||
// tmos_start_task(wf5803_task_id, WF5803_EVT_READ, MS1_TO_SYSTEM_TIME(50));
|
||||
press_task_id = TMOS_ProcessEventRegister(WF5803_ProcessEvent);
|
||||
tmos_set_event(press_task_id, WF5803_EVT_START);
|
||||
}
|
||||
|
|
|
@ -5,15 +5,11 @@
|
|||
|
||||
#define WF5803_EVT_START (0x0001 << 0)
|
||||
#define WF5803_EVT_READ (0x0001 << 1)
|
||||
#define WF5803_EVT_VCC (0x0001 << 2)
|
||||
|
||||
void WF5803_Init(void);
|
||||
// void WF5803_WriteReg(uint8_t Address, uint8_t value);
|
||||
// uint8_t WF5803_ReadReg(uint8_t addr);
|
||||
// uint8_t *GetSensorData(void);
|
||||
// void SensorData_Process(void);
|
||||
void BSPWF5803_Init(void);
|
||||
|
||||
void WF5803_DeInit(void);
|
||||
void PRESS_LowPower(void);
|
||||
|
||||
void BSP_PRESS_Init(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -94,7 +94,7 @@ int main(void)
|
|||
Peripheral_Init();
|
||||
PRINT("Peripheral init ok\n");
|
||||
|
||||
BSPWF5803_Init();
|
||||
BSP_PRESS_Init();
|
||||
PRINT("BSP init ok\n");
|
||||
|
||||
Main_Circulation();
|
||||
|
|
14
HAL/SLEEP.c
14
HAL/SLEEP.c
|
@ -59,8 +59,6 @@ uint32_t CH58x_LowPower(uint32_t time)
|
|||
RTC_SetTignTime(time_tign);
|
||||
SYS_RecoverIrq(irq_status);
|
||||
|
||||
|
||||
|
||||
#if(DEBUG == Debug_UART0) // 使用其他串口输出打印信息需要修改这行代码
|
||||
while((R8_UART0_LSR & RB_LSR_TX_ALL_EMP) == 0)
|
||||
{
|
||||
|
@ -70,21 +68,11 @@ uint32_t CH58x_LowPower(uint32_t time)
|
|||
// LOW POWER-sleep模式
|
||||
if(!RTCTigFlag)
|
||||
{
|
||||
// extern uint8_t volatile vcc4_state;
|
||||
// if (vcc4_state == 0)
|
||||
// {
|
||||
// WF5803_DeInit();
|
||||
// }
|
||||
|
||||
WF5803_DeInit();
|
||||
PRESS_LowPower();
|
||||
|
||||
LowPower_Sleep(RB_PWR_RAM32K | RB_PWR_RAM96K | RB_PWR_EXTEND |RB_XT_PRE_EN );
|
||||
HSECFG_Current(HSE_RCur_100); // 降为额定电流(低功耗函数中提升了HSE偏置电流)
|
||||
|
||||
// if (vcc4_state)
|
||||
// {
|
||||
// WF5803_Init();
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
void SPI0_MasterDefInit(void)
|
||||
{
|
||||
R8_SPI0_CLOCK_DIV = 8; // 主频时钟4分频
|
||||
R8_SPI0_CLOCK_DIV = 4; // 主频时钟4分频
|
||||
R8_SPI0_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI0_CTRL_MOD = RB_SPI_MOSI_OE | RB_SPI_SCK_OE | RB_SPI_MISO_OE;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_AUTO_IF; // 访问BUFFER/FIFO自动清除IF_BYTE_END标志
|
||||
|
|
Loading…
Reference in New Issue