add parse threads
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
|
||||
#include "chrg_thread.h"
|
||||
#include "chrg_roll_sou.h"
|
||||
#include "chrg_switch.h"
|
||||
|
||||
#define LOG_TAG "chrg.rollsou"
|
||||
#include <rtdbg.h>
|
||||
|
||||
|
||||
void chrg_roll_sou_evt_send (void)
|
||||
{
|
||||
struct chrg_thread_t *pTHR = &chrgthr[IDX_THR_ROLL_SOU];
|
||||
if (RT_NULL != pTHR->ev) {
|
||||
rt_event_send(pTHR->ev, ROLL_SOU_EVT_RECVED);
|
||||
}
|
||||
}
|
||||
|
||||
void chrg_roll_sou_thread_entry (void *data)
|
||||
{
|
||||
struct chrg_thread_t *pTHR = (struct chrg_thread_t *)data;
|
||||
|
||||
if (RT_NULL == pTHR) {
|
||||
return ;
|
||||
}
|
||||
|
||||
rt_uint8_t idx = 0;
|
||||
rt_err_t ret = RT_EOK;
|
||||
struct chrg_south_t *pSOU = &chrgsouth;
|
||||
struct chrg_thread_t *pTS = &chrgthr[IDX_THR_SOUTH];
|
||||
struct mb_msg_t *pMB_R = RT_NULL;
|
||||
|
||||
while (1) {
|
||||
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
|
||||
pSOU->idx = idx%(TOTAL_CHS+TOTAL_SOU_CHS);
|
||||
rt_mutex_release(pTHR->mutex);
|
||||
|
||||
if (pSOU->idx < TOTAL_SOU_CHS) {
|
||||
if (0 == pSOU->enable[pSOU->idx]) {
|
||||
idx++;
|
||||
rt_thread_mdelay(10);
|
||||
continue;
|
||||
} else {
|
||||
pSOU->idx = (eIDX_SOU_CH)pSOU->idx;
|
||||
chrg_switch_south(pSOU->idx);
|
||||
|
||||
|
||||
|
||||
//rt_kprintf("Sou[%d].%d\r\n", pSOU->idx, pSOU->id);
|
||||
}
|
||||
}
|
||||
|
||||
idx++;
|
||||
|
||||
ret = rt_mb_recv(pTS->mb, (rt_uint32_t *)&pMB_R, 100); // 超时 100ms
|
||||
if ((RT_EOK == ret)&&(RT_NULL != pMB_R)) {
|
||||
// todo mail data
|
||||
|
||||
|
||||
if (RT_NULL != pMB_R->payload) {
|
||||
rt_free(pMB_R->payload);
|
||||
pMB_R->payload = RT_NULL;
|
||||
}
|
||||
|
||||
if (RT_NULL != pMB_R) {
|
||||
rt_free(pMB_R);
|
||||
pMB_R = RT_NULL;
|
||||
}
|
||||
|
||||
rt_thread_mdelay(50); // 间隔 50ms
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user