1
0
This repository has been archived on 2024-09-17. You can view files and clone it, but cannot push or open issues or pull requests.
tor-heredero-tokenring/mac_sender.c

87 lines
1.8 KiB
C
Raw Normal View History

2024-04-15 14:26:40 +00:00
#include "main.h"
2024-04-10 17:17:57 +00:00
void MacSender(void *argument)
{
// TODO
2024-04-15 14:26:40 +00:00
struct queueMsg_t queueMsg; // queue message
2024-04-17 15:09:48 +00:00
uint8_t* msg;
2024-04-15 14:26:40 +00:00
osStatus_t retCode; // return error code
for(;;) {
//----------------------------------------------------------------------------
// QUEUE READ
//----------------------------------------------------------------------------
retCode = osMessageQueueGet(
queue_macS_id,
&queueMsg,
NULL,
osWaitForever);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
2024-04-17 15:09:48 +00:00
msg = queueMsg.anyPtr;
2024-04-15 14:26:40 +00:00
switch(queueMsg.type) {
case TOKEN:
2024-04-17 15:09:48 +00:00
msg[gTokenInterface.myAddress] = gTokenInterface.station_list[gTokenInterface.myAddress];
for(uint8_t i = 1; i < TOKENSIZE-2; i++) {
gTokenInterface.station_list[i] = msg[i];
}
queueMsg.type = TO_PHY;
retCode = osMessageQueuePut(
queue_phyS_id,
&queueMsg,
osPriorityNormal,
osWaitForever);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
2024-04-15 14:26:40 +00:00
break;
case DATABACK:
break;
case NEW_TOKEN:
2024-04-17 15:09:48 +00:00
msg = osMemoryPoolAlloc(memPool, osWaitForever);
msg[0] = TOKEN_TAG;
for(uint8_t i = 1; i < sizeof(TOKENSIZE-2); i++) {
msg[i] = 0;
2024-04-15 14:26:40 +00:00
}
2024-04-17 15:09:48 +00:00
gTokenInterface.station_list[gTokenInterface.myAddress] = (0x1 << TIME_SAPI) + (gTokenInterface.connected << CHAT_SAPI);
msg[gTokenInterface.myAddress+1] = gTokenInterface.station_list[gTokenInterface.myAddress];
2024-04-15 14:26:40 +00:00
queueMsg.type = TO_PHY;
2024-04-17 15:09:48 +00:00
queueMsg.anyPtr = msg;
retCode = osMessageQueuePut(
queue_phyS_id,
&queueMsg,
osPriorityNormal,
osWaitForever);
CheckRetCode(retCode, __LINE__, __FILE__, CONTINUE);
2024-04-15 14:26:40 +00:00
break;
case START:
break;
case STOP:
break;
case DATA_IND:
break;
default:
break;
}
}
2024-04-10 17:17:57 +00:00
}