This commit is contained in:
parent
9a760f0c11
commit
3cdccc4d63
|
@ -164,5 +164,5 @@
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||||
<storageModule moduleId="refreshScope"/>
|
|
||||||
</cproject>
|
</cproject>
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#define SBP_PHY_UPDATE_DELAY 2400
|
#define SBP_PHY_UPDATE_DELAY 2400
|
||||||
|
|
||||||
// What is the advertising interval when device is discoverable (units of 625us, 80=50ms)
|
// What is the advertising interval when device is discoverable (units of 625us, 80=50ms)
|
||||||
#define DEFAULT_ADVERTISING_INTERVAL (160 * 10)
|
#define DEFAULT_ADVERTISING_INTERVAL (160 * 1)
|
||||||
|
|
||||||
// Limited discoverable mode advertises for 30.72s, and then stops
|
// Limited discoverable mode advertises for 30.72s, and then stops
|
||||||
// General discoverable mode advertises indefinitely
|
// General discoverable mode advertises indefinitely
|
||||||
|
@ -136,6 +136,71 @@ static uint8_t advertData[] = {
|
||||||
HI_UINT16(SIMPLEPROFILE_SERV_UUID)
|
HI_UINT16(SIMPLEPROFILE_SERV_UUID)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// 蓝牙广播包的最大长度是37个字节,其中设备地址占用了6个字节,只有31个字节是可用的。
|
||||||
|
|
||||||
|
// GAP - SCAN RSP data (max size = 31 bytes)
|
||||||
|
static uint8_t scanRspData[] = {
|
||||||
|
// complete name
|
||||||
|
0x08, // length of this data
|
||||||
|
GAP_ADTYPE_LOCAL_NAME_COMPLETE,
|
||||||
|
'B',
|
||||||
|
'L',
|
||||||
|
'E',
|
||||||
|
'-',
|
||||||
|
'T',
|
||||||
|
'Y',
|
||||||
|
'Q',
|
||||||
|
|
||||||
|
// connection interval range
|
||||||
|
0x05, // length of this data
|
||||||
|
GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE,
|
||||||
|
LO_UINT16(DEFAULT_DESIRED_MIN_CONN_INTERVAL), // 100ms
|
||||||
|
HI_UINT16(DEFAULT_DESIRED_MIN_CONN_INTERVAL),
|
||||||
|
LO_UINT16(DEFAULT_DESIRED_MAX_CONN_INTERVAL), // 1s
|
||||||
|
HI_UINT16(DEFAULT_DESIRED_MAX_CONN_INTERVAL),
|
||||||
|
|
||||||
|
// Tx power level
|
||||||
|
0x02, // length of this data
|
||||||
|
GAP_ADTYPE_POWER_LEVEL,
|
||||||
|
0 // 0dBm
|
||||||
|
|
||||||
|
0x03, // length of this data
|
||||||
|
GAP_ADTYPE_MANUFACTURER_SPECIFIC,
|
||||||
|
// 前两个字节表示厂商 ID
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0x10, // 1B 电池电压 30=3V,18=1.8V
|
||||||
|
0x01, // 1B 阀门类型
|
||||||
|
0x00, // 1B 阀门工作状态 超欠压、过流
|
||||||
|
0x00, // 1B 阀门连接状态 (电磁阀BLE控制盒) 0=未连接 1=已连接
|
||||||
|
0x01, // 1B 阀门开关状态 0=未知 1=关闭 2=关闭过,未按按键恢复 3=关闭过,按下了恢复键 4=打开
|
||||||
|
0x03, // 1B 阀门温度 有符号整数 25 C
|
||||||
|
0x04, // 1B 阀门进口压力 0~156 (0)kPa
|
||||||
|
0x05, // 1B 阀门出口压力 0~100 hPa 0.1kpa
|
||||||
|
0x06, // 1B 阀门大气压力 80~110 kPa
|
||||||
|
};
|
||||||
|
|
||||||
|
// GAP - Advertisement data (max size = 31 bytes, though this is
|
||||||
|
// best kept short to conserve power while advertising)
|
||||||
|
static uint8_t advertData[] = {
|
||||||
|
// Flags; this sets the device to use limited discoverable
|
||||||
|
// mode (advertises for 30 seconds at a time) instead of general
|
||||||
|
// discoverable mode (advertises indefinitely)
|
||||||
|
0x02, // length of this data
|
||||||
|
GAP_ADTYPE_FLAGS,
|
||||||
|
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
|
||||||
|
|
||||||
|
// service UUID, to notify central devices what services are included
|
||||||
|
// in this peripheral
|
||||||
|
0x03, // length of this data
|
||||||
|
GAP_ADTYPE_16BIT_MORE, // some of the UUID's, but not all
|
||||||
|
LO_UINT16(SIMPLEPROFILE_SERV_UUID),
|
||||||
|
HI_UINT16(SIMPLEPROFILE_SERV_UUID)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// GAP GATT Attributes
|
// GAP GATT Attributes
|
||||||
static uint8_t attDeviceName[GAP_DEVICE_NAME_LEN] = "Simple Peripheral";
|
static uint8_t attDeviceName[GAP_DEVICE_NAME_LEN] = "Simple Peripheral";
|
||||||
|
|
||||||
|
@ -227,6 +292,12 @@ void Peripheral_Init()
|
||||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MIN, advInt);
|
GAP_SetParamValue(TGAP_DISC_ADV_INT_MIN, advInt);
|
||||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MAX, advInt);
|
GAP_SetParamValue(TGAP_DISC_ADV_INT_MAX, advInt);
|
||||||
|
|
||||||
|
// https://www.cnblogs.com/debugdabiaoge/p/17871551.html
|
||||||
|
// 默认从机在回复扫描请求后,会结束广播事件(默认广播应该是 37 38 39 在 3 个信道轮发)
|
||||||
|
// 如下使能后,可以保证广播包不受扫描请求的影响
|
||||||
|
// uint16_t adv_event_contnue=1<<1;
|
||||||
|
// GAP_SetParamValue(TGAP_ADV_SCAN_REQ_NOTIFY, adv_event_contnue);
|
||||||
|
|
||||||
// Enable scan req notify
|
// Enable scan req notify
|
||||||
GAP_SetParamValue(TGAP_ADV_SCAN_REQ_NOTIFY, ENABLE);
|
GAP_SetParamValue(TGAP_ADV_SCAN_REQ_NOTIFY, ENABLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,32 +49,32 @@ __attribute__((noinline)) void Main_Circulation()
|
||||||
// LED
|
// LED
|
||||||
GPIOA_SetBits(GPIO_Pin_4);
|
GPIOA_SetBits(GPIO_Pin_4);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_4, GPIO_ModeOut_PP_5mA);
|
GPIOA_ModeCfg(GPIO_Pin_4, GPIO_ModeOut_PP_5mA);
|
||||||
DelayMs(50);
|
DelayMs(1000);
|
||||||
PRINT("LED ON\n");
|
PRINT("LED ON\n");
|
||||||
|
|
||||||
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15);
|
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD);
|
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD);
|
||||||
DelayMs(50);
|
DelayMs(1000);
|
||||||
PRINT("LED OFF\n");
|
PRINT("LED OFF\n");
|
||||||
|
|
||||||
GPIOA_SetBits(GPIO_Pin_5);
|
GPIOA_SetBits(GPIO_Pin_5);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_5, GPIO_ModeOut_PP_5mA);
|
GPIOA_ModeCfg(GPIO_Pin_5, GPIO_ModeOut_PP_5mA);
|
||||||
DelayMs(50);
|
DelayMs(1000);
|
||||||
PRINT("LED ON\n");
|
PRINT("LED ON\n");
|
||||||
|
|
||||||
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15);
|
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD);
|
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD);
|
||||||
DelayMs(50);
|
DelayMs(1000);
|
||||||
PRINT("LED OFF\n");
|
PRINT("LED OFF\n");
|
||||||
|
|
||||||
GPIOA_SetBits(GPIO_Pin_15);
|
GPIOA_SetBits(GPIO_Pin_15);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_4, GPIO_ModeOut_PP_5mA);
|
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeOut_PP_5mA);
|
||||||
DelayMs(50);
|
DelayMs(1000);
|
||||||
PRINT("LED ON\n");
|
PRINT("LED ON\n");
|
||||||
|
|
||||||
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15);
|
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD);
|
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD);
|
||||||
DelayMs(50);
|
DelayMs(1000);
|
||||||
PRINT("LED OFF\n");
|
PRINT("LED OFF\n");
|
||||||
|
|
||||||
DelayMs(100);
|
DelayMs(100);
|
||||||
|
@ -87,8 +87,6 @@ __attribute__((noinline)) void Main_Circulation()
|
||||||
|
|
||||||
DelayMs(1000 * 5);
|
DelayMs(1000 * 5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// EMV_CTRL
|
// EMV_CTRL
|
||||||
GPIOB_SetBits(GPIO_Pin_13);
|
GPIOB_SetBits(GPIO_Pin_13);
|
||||||
GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
|
GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
|
||||||
|
@ -116,15 +114,30 @@ int main(void)
|
||||||
PWR_DCDCCfg(ENABLE);
|
PWR_DCDCCfg(ENABLE);
|
||||||
#endif
|
#endif
|
||||||
SetSysClock(CLK_SOURCE_PLL_60MHz);
|
SetSysClock(CLK_SOURCE_PLL_60MHz);
|
||||||
|
|
||||||
#if (defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
#if (defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
||||||
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
|
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PD);
|
||||||
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
|
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PD);
|
||||||
|
#endif
|
||||||
|
#ifdef DEBUG
|
||||||
|
GPIOB_SetBits(bTXD0);
|
||||||
|
GPIOB_ModeCfg(bTXD0, GPIO_ModeOut_PP_5mA);
|
||||||
|
UART0_DefInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 12V_EN
|
// 12V_EN
|
||||||
GPIOA_ResetBits(GPIO_Pin_13);
|
GPIOA_ResetBits(GPIO_Pin_13);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
|
GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
|
||||||
|
|
||||||
|
// EMV_CTRL
|
||||||
|
GPIOB_SetBits(GPIO_Pin_13);
|
||||||
|
GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
|
||||||
|
PRINT("EMV_CTRL ON\n");
|
||||||
|
DelayMs(100);
|
||||||
|
|
||||||
|
GPIOB_ResetBits(GPIO_Pin_13);
|
||||||
|
PRINT("EMV_CTRL OFF\n");
|
||||||
|
|
||||||
// EMV_CTRL
|
// EMV_CTRL
|
||||||
GPIOB_ResetBits(GPIO_Pin_13);
|
GPIOB_ResetBits(GPIO_Pin_13);
|
||||||
GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_PD);
|
GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_PD);
|
||||||
|
@ -148,11 +161,8 @@ int main(void)
|
||||||
// GPIOA_ResetBits(GPIO_Pin_1);
|
// GPIOA_ResetBits(GPIO_Pin_1);
|
||||||
GPIOA_ModeCfg(GPIO_Pin_14, GPIO_ModeIN_Floating);
|
GPIOA_ModeCfg(GPIO_Pin_14, GPIO_ModeIN_Floating);
|
||||||
|
|
||||||
#ifdef DEBUG
|
DelayMs(1000 * 5);
|
||||||
GPIOB_SetBits(bTXD0);
|
|
||||||
GPIOB_ModeCfg(bTXD0, GPIO_ModeOut_PP_5mA);
|
|
||||||
UART0_DefInit();
|
|
||||||
#endif
|
|
||||||
PRINT("%s\n", VER_LIB);
|
PRINT("%s\n", VER_LIB);
|
||||||
CH59x_BLEInit();
|
CH59x_BLEInit();
|
||||||
HAL_Init();
|
HAL_Init();
|
||||||
|
|
Loading…
Reference in New Issue