一:系统篇:
软件复位
SYS_ResetExecute();
延时函数
mDelaymS(1); //延时1ms
mDelayuS(1); //延时1us
设置晶体匹配电容
void HSECFG_Capacitance(HSECapTypeDef c); //外部高频32MHZ
void LSECFG_Capacitance(LSECapTypeDef c); //外部低频32.768KHZ
开启DCDC降低功耗
void PWR_DCDCCfg(FunctionalState s);
二:蓝牙篇
获取芯片唯一MAC
uint8_t MacAddr[6];
GetMACAddress(MacAddr);
查询蓝牙连接状态
extern uint8_t linkDB_State( uint16_t connectionHandle, uint8_t state );
蓝牙交互MTU
extern bStatus_t GATT_ExchangeMTU( uint16_t connHandle, attExchangeMTUReq_t *pReq, uint8_t taskId );
蓝牙主动断开连接(主机和从机都适用)
extern bStatus_t GAPRole_TerminateLink( uint16_t connHandle );
蓝牙从机开关广播
uint8_t advertising_enable = TRUE; GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &advertising_enable); //开启广播
uint8_t advertising_enable = FALSE;
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &advertising_enable); //关闭广播
蓝牙从机更新广播内容
extern bStatus_t GAP_UpdateAdvertisingData( uint8_t taskID, uint8_t adType, uint8_t dataLen, uint8_t *pAdvertData );
蓝牙从机更新连接参数
extern bStatus_t GAPRole_PeripheralConnParamUpdateReq( uint16_t connHandle, uint16_t connIntervalMin, uint16_t connIntervalMax, uint16_t latency, uint16_t connTimeout, uint8_t taskId );
蓝牙主机开启扫描
extern bStatus_t GAPRole_CentralStartDiscovery( uint8_t mode, uint8_t activeScan, uint8_t whiteList );
蓝牙主机取消扫描
extern bStatus_t GAPRole_CentralCancelDiscovery( void );
蓝牙主机发起连接
extern bStatus_t GAPRole_CentralEstablishLink( uint8_t highDutyCycle, uint8_t whiteList, uint8_t addrTypePeer, uint8_t *peerAddr );
蓝牙从机配置广播通道
uint8_t advertChannel=GAP_ADVCHAN_37; GAPRole_SetParameter(GAPROLE_ADV_CHANNEL_MAP, sizeof(uint8_t), &advertChannel); // GAP_ADVCHAN_DEFINES GAP Advertisement Channel Map #define GAP_ADVCHAN_37 0x01 //!< Advertisement Channel 37 #define GAP_ADVCHAN_38 0x02 //!< Advertisement Channel 38 #define GAP_ADVCHAN_39 0x04 //!< Advertisement Channel 39 #define GAP_ADVCHAN_ALL (GAP_ADVCHAN_37 | GAP_ADVCHAN_38 | GAP_ADVCHAN_39) //!< All Advertisement Channels Enabled
updata...