EETimes

Embedded Systems October 2000 Vol13_11

Issue link: http://dc.ee.ubm-us.com/i/71842

Contents of this Issue

Navigation

Page 135 of 181

be no increase or a slight decrease in LOtal ROM usage d ue to the efficiencies of in tegrating functions into the API instead of creating multiple functions. Message The message me thod is almost identi- cal to the API call s me thod, except th at it uses th e RTOS' inte rprocess L1STINCi 11 Generic routine for sampling discrete inputs void SampLeOiscreteInput(IOHANOlE name) { U8 RawOigitaL = *«OigitaLInputRom *)name->port & «OigitaLInputRom *)name->mask; OebounceOiscrete(RawOigitaL, name); } communicatio n (IPC) system to trans- fe r the status of the data. A maj or assumptio n is that the RTOS IPC pro- vides messages that are not consumed when th ey are received . An example is the OSEK/ VDX unqueued message in the COM specifi cation . (See my previous OSEK/ VDX articles in ESP. "OSEK/ VDX tandard: Ope rating ystem and Communicatio n," March 2000, p. 90; and "OSEK/ VDX Network Manager and void CheckReLay(void) { if«GetOiscreteState(&switch1)==INACTIVE) I I (GetOiscreteState(&switch2) == INACTIVE» { SetOiscreteState(&reLay,INACTIVE); } eLse { SetOiscreteState(&reLay,ACTIVE); } TenminateTask(); } Impleme nta tio n La nguage," April 2000, p. 96.) Unque ued messages re ta in the last value, and can be "received" multip le times without los- ing the value . T he diffe ren ces between message and API calls meth- ods are: • Type defin itio ns change slightly • ReceiveMessage instead of tile API fun ctio n Get • SendMessage instead of the API functio n Set • Defin itio n of messages fo r all inputs required L1STINCi 13 Discrete input structure with message field typedef void * IOHANOlE; typedef struct OigitaLInputRamtag { U8 rawva Lue; U8 debouncedvaLue; U8 time[8J; } OigitaLInputRam; typedef struct OigitaLInputRomtag { U8 *digitaLport; U8 mask; U8 debouncetime; U8 ramLocation; U8 rarnnask; MESSAGE message; BOOLEAN defauLtstate; } OigitaLInputRom; 134 OCTOBER 2000 Embedded Syst ems Programming Routines The access rou t i nes have been replaced by the IPC ro utines, and the input sampling routine cha nges slig htly as shown in Listing 15. The addi t io n of the SendMes sage functio n p laces th e resul t in the sys- tem message for use by th e algo- r ithms. T he DebounceDiscrete fun c- tio n re turns the debo unced state of th e discrete. Type definitions From the example in API calls of tile digital input, the RAM type variable does not change. However, the ROM type variable adds a refere nce to the message that contains me input as shown in Listing 13. Macros Since the ROM structure changed, a change needs to be made to tile macro that creates the structure instances to include the name of the message, as shown in Listing 14.

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems October 2000 Vol13_11