Amulet Data Pool and Serial State Code for the Amulet Technologies
Easy GUI display. This code was modified for the UCOS-II OS and Paradigm
compiler based on code from Jonathan Somers, see AppNote
for an excellent description of the code.
Setting and reading of variables within the pool are protected by a critical section. This allows you to have a single task assigned to handle communication with the Amulet while other tasks are free to update the variables without fear of corruption. A special note for String Variable types, in a multitasking OS there is the problem that one task may update a string variable just as we want to send it to the Amulet. Therefore we must deep copy the string before handing it back to the serial code component. This way the task that is reading the value will get valid data. You must also protect writing to the String variable with a critical section. Note this may prove slow and cause unacceptable interrupt latency since OS_ENTER_CRITICAL() disables interrupts. A better approach may be to override this default function and assign a semaphore for access control of the string.
The declaration of the Variable Pool arrays were changed so that only a pool large enough is declared, to save on data space. The implementation could be refined further to reduce memory usage. In addition the assert macro was added to each function to ensure that no attempt to get a value outside of the 'pool' is done (which would cause access to invalid memory). So run time checking is only done in debug mode. Variable declarations were changed to use UCOS-II types.
To use call LcdInitialize() once at startup and then call LcdProcessReceivedChars() in a UCOS-II task. All requests will be responded to immediately unless the task is preempted by an ISR or higher priority task. To comply with the Amulet timeout of 200ms, be sure that task latency is not longer than this.
void TaskAmuletComm(void* data)
{
LcdInitialize(COMM1);
LcdProcessReceivedCharacters();
}
amuletucosii.zip unzip and place the code in \Software\Blocks\Amulet\
...develop, race, win!