This repository was archived by the owner on Oct 11, 2019. It is now read-only.
srobo-legacy/boards-interconnect-fw
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
The token passing code works something like the following:
TO = HT = 0;
pause(2);
while(1) {
if(TI) { // Got the token
if(RT) { // Do we want to use the token
HT = 1;
while(RT); // Wait until finished using the token
HT = 0;
}
while(TI); // Wait for the whole of the token to arrive
TO = 1;
pause(TOKEN_LENGTH); // Send the token on its way
TO = 0;
}
}
The token generator, for debugging purposes, works like:
GenerateToken // Input, active low
RemoveToken // Input, active low
pause(2);
while(1) {
if(!GenerateToken) { // Should generate a new token
pause(10m); // Debouncing
while(!GenerateToken); // Only send it when button is released
TO = 1;
pause(TOKEN_LENGTH);
TO = 0;
}
if (TI) { // Normal token handling (passing on)
while(TI);
if (RemoveToken) { // Don't pass token on if it's to be removed
TO = 1;
pause(TOKEN_LENGTH);
TO = 0;
}
}
}