//! initialize a unit
/**
\param ucUnit number of the unit (descriptor array index [not the hardware index] of adcdev.h)
\param ucChannel (unused, set 0) number of the sub-channel for units tree(s)
\param oiSemMsgNew (optional, set to NULL as default) OS_ID of pre-initialized (to 0!) semaphore to send/give for matching messages
\param usChannelMask (optional, set to 0 as default) triggered channels to take into account for unit semaphore triggering
\param ulMsgMask (optional, set to NULL as default) and-mask to include triggered channels' messages for unit semaphore triggering
\param ulMsgChangeMask (optional, set to NULL as default) mask to suppress (bit set) same message triggering and to trigger only for a message change
\return > 0 for success, == 0 for failure
\note
- 3 tasks are spanned by this function
- message bits are composed of software bits (trigger message bits of adc.h) and filtered hardware bits (refer to AT91SAM7X manual 35.6.6 page 498: ADC_SR) by u32IrqMsg of _SAdcRO
Example: merge all channel semaphores to a single unit semaphore you need:
- configure ulMsgMask & ulMsgChangeMask of all required channels (#AdcInitChannel)
- select channels to merge: usChannelMask= AT91C_ADC_CHx | AT91C_ADC_CHy | ...
- set unit message filter: ulMsgMask= AdcCfgChannel[x].ulMsgMask | AdcCfgChannel[y].ulMsgMask | ...
- set unit change mask: ulMsgChangeMask= (0xFFFFFFFF & AdcCfgChannel[x].ulMsgChangeMask) & (0xFFFFFFFF & AdcCfgChannel[y].ulMsgChangeMask) & ...
- assign #OS_ID of your pre-initialized (with 0!) semaphore: oiSemMsgNew= ...
Manual reference(s):
AT91SAM7X manual 35.6.6 page 498: ADC_SR
*/
UCHAR AdcInitUnit (UCHAR ucUnit, UCHAR ucChannel, OS_ID oiSemMsgNew, USHORT usChannelMask, ULONG ulMsgMask, ULONG ulMsgChangeMask);