update 1.8
This commit is contained in:
@@ -69,6 +69,7 @@ void Main_Circulation(void)
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SystemCoreClockUpdate();
|
||||
Delay_Init();
|
||||
#ifdef DEBUG
|
||||
USART_Printf_Init( 115200 );
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void BB_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
void LLE_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
|
||||
/*********************************************************************
|
||||
* @fn NMI_Handler
|
||||
@@ -60,15 +59,3 @@ void BB_IRQHandler(void)
|
||||
{
|
||||
BB_IRQLibHandler();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LLE_IRQHandler
|
||||
*
|
||||
* @brief LLE Interrupt for BLE.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void LLE_IRQHandler(void)
|
||||
{
|
||||
LLE_IRQLibHandler();
|
||||
}
|
||||
|
||||
@@ -15,12 +15,9 @@
|
||||
//每个文件单独debug打印的开关,置0可以禁止本文件内部打印
|
||||
#define DEBUG_PRINT_IN_THIS_FILE 1
|
||||
#if DEBUG_PRINT_IN_THIS_FILE
|
||||
#define PRINTF(...) PRINT(__VA_ARGS__)
|
||||
#define PRINTF(...) PRINT(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...) \
|
||||
do \
|
||||
{ \
|
||||
} while(0)
|
||||
#define PRINTF(...) do{} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -68,6 +65,33 @@ static uint8_t ble_phy_channelmap_send_seq = 0, bl
|
||||
static struct blemesh_mac_phy_manage_struct *blemesh_phy_manage_list_head = NULL; //mac管理发送LIST列表指针
|
||||
static struct blemesh_mac_phy_manage_struct blemesh_phy_manage_list[LWNS_MAC_SEND_PACKET_MAX_NUM]; //mac管理发送列表管理数组
|
||||
|
||||
volatile uint8_t tx_end_flag=0;
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RF_Wait_Tx_End
|
||||
*
|
||||
* @brief 手动模式等待发送完成,自动模式等待发送-接收完成,必须在RAM中等待,等待时可以执行用户代码,但需要注意执行的代码必须运行在RAM中,否则影响发送
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((section(".highcode")))
|
||||
__attribute__((noinline))
|
||||
void RF_Wait_Tx_End()
|
||||
{
|
||||
uint32_t i=0;
|
||||
while(!tx_end_flag)
|
||||
{
|
||||
i++;
|
||||
__NOP();
|
||||
__NOP();
|
||||
// 约5ms超时
|
||||
if(i>(SystemCoreClock/1000))
|
||||
{
|
||||
tx_end_flag = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RF_2G4StatusCallBack
|
||||
*
|
||||
@@ -416,9 +440,12 @@ static uint16_t lwns_phyoutput_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||
}
|
||||
RF_Shut();
|
||||
RF_SetChannel(ble_phy_channelmap[ble_phy_channelmap_send_seq]); //周期性更改发送通道
|
||||
RF_Tx((uint8_t *)(blemesh_phy_manage_list_head->data + 1),
|
||||
if(!RF_Tx((uint8_t *)(blemesh_phy_manage_list_head->data + 1),
|
||||
blemesh_phy_manage_list_head->data[0], USER_RF_RX_TX_TYPE,
|
||||
USER_RF_RX_TX_TYPE);
|
||||
USER_RF_RX_TX_TYPE))
|
||||
{
|
||||
RF_Wait_Tx_End();
|
||||
}
|
||||
tmos_start_task(lwns_phyoutput_taskid, LWNS_PHY_OUTPUT_FINISH_EVT, MS1_TO_SYSTEM_TIME(LWNS_PHY_OUTPUT_TIMEOUT_MS)); //开始发送超时计数,防止有意外打断发送,导致无法继续发送
|
||||
ble_phy_channelmap_send_seq++;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,9 @@
|
||||
//每个文件单独debug打印的开关,置0可以禁止本文件内部打印
|
||||
#define DEBUG_PRINT_IN_THIS_FILE 1
|
||||
#if DEBUG_PRINT_IN_THIS_FILE
|
||||
#define PRINTF(...) PRINT(__VA_ARGS__)
|
||||
#define PRINTF(...) PRINT(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...) \
|
||||
do \
|
||||
{ \
|
||||
} while(0)
|
||||
#define PRINTF(...) do{} while(0)
|
||||
#endif
|
||||
|
||||
#if LWNS_USE_CSMA_MAC //是否使能模仿csma的mac协议,注意只能使能一个mac层协议。
|
||||
@@ -61,6 +58,33 @@ static uint8_t ble_phy_manage_state, ble_phy_send_cnt
|
||||
static struct csma_mac_phy_manage_struct *csma_phy_manage_list_head = NULL; //mac管理发送列表指针
|
||||
static struct csma_mac_phy_manage_struct csma_phy_manage_list[LWNS_MAC_SEND_PACKET_MAX_NUM]; //mac管理发送列表管理数组
|
||||
|
||||
volatile uint8_t tx_end_flag=0;
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RF_Wait_Tx_End
|
||||
*
|
||||
* @brief 手动模式等待发送完成,自动模式等待发送-接收完成,必须在RAM中等待,等待时可以执行用户代码,但需要注意执行的代码必须运行在RAM中,否则影响发送
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((section(".highcode")))
|
||||
__attribute__((noinline))
|
||||
void RF_Wait_Tx_End()
|
||||
{
|
||||
uint32_t i=0;
|
||||
while(!tx_end_flag)
|
||||
{
|
||||
i++;
|
||||
__NOP();
|
||||
__NOP();
|
||||
// 约5ms超时
|
||||
if(i>(SystemCoreClock/1000))
|
||||
{
|
||||
tx_end_flag = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RF_2G4StatusCallBack
|
||||
*
|
||||
@@ -416,9 +440,12 @@ static uint16_t lwns_phyoutput_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||
tmos_clear_event(lwns_adapter_taskid, LWNS_PHY_RX_OPEN_EVT); //停止可能已经置位的、可能会打开接收的任务
|
||||
}
|
||||
RF_Shut();
|
||||
RF_Tx((uint8_t *)(csma_phy_manage_list_head->data + 1),
|
||||
if(!RF_Tx((uint8_t *)(csma_phy_manage_list_head->data + 1),
|
||||
csma_phy_manage_list_head->data[0], USER_RF_RX_TX_TYPE,
|
||||
USER_RF_RX_TX_TYPE);
|
||||
USER_RF_RX_TX_TYPE))
|
||||
{
|
||||
RF_Wait_Tx_End();
|
||||
}
|
||||
tmos_start_task(lwns_phyoutput_taskid, LWNS_PHY_OUTPUT_FINISH_EVT, MS1_TO_SYSTEM_TIME(LWNS_PHY_OUTPUT_TIMEOUT_MS)); //开始发送超时计数
|
||||
return (events ^ LWNS_PHY_OUTPUT_EVT);
|
||||
}
|
||||
|
||||
@@ -15,12 +15,9 @@
|
||||
//每个文件单独debug打印的开关,置0可以禁止本文件内部打印
|
||||
#define DEBUG_PRINT_IN_THIS_FILE 1
|
||||
#if DEBUG_PRINT_IN_THIS_FILE
|
||||
#define PRINTF(...) PRINT(__VA_ARGS__)
|
||||
#define PRINTF(...) PRINT(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...) \
|
||||
do \
|
||||
{ \
|
||||
} while(0)
|
||||
#define PRINTF(...) do{} while(0)
|
||||
#endif
|
||||
|
||||
#if LWNS_USE_NO_MAC //是否使能纯透传mac协议,即mac层不参与任何动作,注意只能使能一个mac层协议。
|
||||
@@ -59,6 +56,33 @@ static lwns_fuc_interface_t ble_lwns_fuc_interface = {
|
||||
|
||||
static uint8_t ble_phy_manage_state; //phy状态管理
|
||||
|
||||
volatile uint8_t tx_end_flag=0;
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RF_Wait_Tx_End
|
||||
*
|
||||
* @brief 手动模式等待发送完成,自动模式等待发送-接收完成,必须在RAM中等待,等待时可以执行用户代码,但需要注意执行的代码必须运行在RAM中,否则影响发送
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((section(".highcode")))
|
||||
__attribute__((noinline))
|
||||
void RF_Wait_Tx_End()
|
||||
{
|
||||
uint32_t i=0;
|
||||
while(!tx_end_flag)
|
||||
{
|
||||
i++;
|
||||
__NOP();
|
||||
__NOP();
|
||||
// 约5ms超时
|
||||
if(i>(SystemCoreClock/1000))
|
||||
{
|
||||
tx_end_flag = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RF_2G4StatusCallBack
|
||||
*
|
||||
@@ -356,7 +380,10 @@ static uint16_t lwns_phyoutput_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||
// Release the TMOS message,tmos_msg_allocate
|
||||
tmos_clear_event(lwns_adapter_taskid, LWNS_PHY_RX_OPEN_EVT); //停止可能已经置位的、可能会打开接收的任务
|
||||
RF_Shut();
|
||||
RF_Tx((uint8_t *)(pMsg + 1), pMsg[0], USER_RF_RX_TX_TYPE, USER_RF_RX_TX_TYPE);
|
||||
if(!RF_Tx((uint8_t *)(pMsg + 1), pMsg[0], USER_RF_RX_TX_TYPE, USER_RF_RX_TX_TYPE))
|
||||
{
|
||||
RF_Wait_Tx_End();
|
||||
}
|
||||
tmos_start_task(lwns_phyoutput_taskid, LWNS_PHY_OUTPUT_FINISH_EVT, MS1_TO_SYSTEM_TIME(LWNS_PHY_OUTPUT_TIMEOUT_MS)); //开始发送超时计数,防止有意外打断发送,导致无法继续发送
|
||||
tmos_msg_deallocate(pMsg); //释放内存
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user