28 #if (HAL_USE_PAL == TRUE) || defined(__DOXYGEN__) 44 #define PAL_MODE_RESET 0U 53 #define PAL_MODE_UNCONNECTED 1U 58 #define PAL_MODE_INPUT 2U 63 #define PAL_MODE_INPUT_PULLUP 3U 68 #define PAL_MODE_INPUT_PULLDOWN 4U 73 #define PAL_MODE_INPUT_ANALOG 5U 78 #define PAL_MODE_OUTPUT_PUSHPULL 6U 83 #define PAL_MODE_OUTPUT_OPENDRAIN 7U 105 #define PAL_EVENT_MODE_EDGES_MASK 3U 106 #define PAL_EVENT_MODE_DISABLED 0U 107 #define PAL_EVENT_MODE_RISING_EDGE 1U 108 #define PAL_EVENT_MODE_FALLING_EDGE 2U 109 #define PAL_EVENT_MODE_BOTH_EDGES 3U 124 #if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) 125 #define PAL_USE_CALLBACKS TRUE 132 #if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) 133 #define PAL_USE_WAIT TRUE 150 #if (PAL_USE_WAIT == TRUE) || (PAL_USE_CALLBACKS == TRUE) || defined(__DOXYGEN__) 155 #if (PAL_USE_WAIT == TRUE) || defined(__DOXYGEN__) 161 #if (PAL_USE_CALLBACKS == TRUE) || defined(__DOXYGEN__) 211 #if !defined(PAL_PORT_BIT) || defined(__DOXYGEN__) 212 #define PAL_PORT_BIT(n) ((ioportmask_t)(1U << (n))) 222 #if !defined(PAL_GROUP_MASK) || defined(__DOXYGEN__) 223 #define PAL_GROUP_MASK(width) ((ioportmask_t)(1U << (width)) - 1U) 236 #define _IOBUS_DATA(name, port, width, offset) \ 237 {port, PAL_GROUP_MASK(width), offset} 247 #define IOBUS_DECL(name, port, width, offset) \ 248 IOBus name = _IOBUS_DATA(name, port, width, offset) 250 #if (PAL_USE_CALLBACKS == TRUE) || (PAL_USE_WAIT == TRUE) || \ 256 #if ((PAL_USE_CALLBACKS == TRUE) && (PAL_USE_WAIT == TRUE)) || \ 265 #define _pal_init_event(e) \ 267 osalThreadQueueObjectInit(&_pal_events[e].threads); \ 268 _pal_events[e].cb = NULL; \ 269 _pal_events[e].arg = NULL; \ 273 #if (PAL_USE_CALLBACKS == TRUE) && (PAL_USE_WAIT == FALSE) 274 #define _pal_init_event(e) \ 276 _pal_events[e].cb = NULL; \ 277 _pal_events[e].arg = NULL; \ 281 #if (PAL_USE_CALLBACKS == FALSE) && (PAL_USE_WAIT == TRUE) 282 #define _pal_init_event(e) \ 284 osalThreadQueueObjectInit(&_pal_events[e].threads); \ 288 #if ((PAL_USE_CALLBACKS == TRUE) && (PAL_USE_WAIT == TRUE)) || defined(__DOXYGEN__) 296 #define _pal_clear_event(e) \ 298 osalThreadDequeueAllI(&_pal_events[pad].threads, MSG_RESET); \ 299 _pal_events[e].cb = NULL; \ 300 _pal_events[e].arg = NULL; \ 304 #if (PAL_USE_CALLBACKS == TRUE) && (PAL_USE_WAIT == FALSE) 305 #define _pal_clear_event(e) \ 307 _pal_events[e].cb = NULL; \ 308 _pal_events[e].arg = NULL; \ 312 #if (PAL_USE_CALLBACKS == FALSE) && (PAL_USE_WAIT == TRUE) 313 #define _pal_clear_event(e) \ 315 osalThreadDequeueAllI(&_pal_events[pad].threads, MSG_RESET); \ 328 #if ((PAL_USE_CALLBACKS == TRUE) && (PAL_USE_WAIT == TRUE)) || \ 330 #define _pal_isr_code(e) do { \ 331 if (_pal_events[e].cb != NULL) { \ 332 _pal_events[e].cb(_pal_events[e].arg); \ 334 osalSysLockFromISR(); \ 335 osalThreadDequeueAllI(&_pal_events[e].threads, MSG_OK); \ 336 osalSysUnlockFromISR(); \ 340 #if (PAL_USE_CALLBACKS == TRUE) && (PAL_USE_WAIT == FALSE) 341 #define _pal_isr_code(e) do { \ 342 if (_pal_events[e].cb != NULL) { \ 343 _pal_events[e].cb(_pal_events[e].arg); \ 348 #if ((PAL_USE_CALLBACKS == FALSE) && (PAL_USE_WAIT == TRUE)) || \ 350 #define _pal_isr_code(e) do { \ 351 osalSysLockFromISR(); \ 352 osalThreadDequeueAllI(&_pal_events[e].threads, MSG_OK); \ 353 osalSysUnlockFromISR(); \ 371 #if defined(PAL_NEW_INIT) || defined(__DOXYGEN__) 372 #define palInit() pal_lld_init() 374 #define palInit(config) pal_lld_init(config) 386 #if !defined(pal_lld_readport) || defined(__DOXYGEN__) 387 #define palReadPort(port) ((void)(port), 0U) 389 #define palReadPort(port) pal_lld_readport(port) 403 #if !defined(pal_lld_readlatch) || defined(__DOXYGEN__) 404 #define palReadLatch(port) ((void)(port), 0U) 406 #define palReadLatch(port) pal_lld_readlatch(port) 418 #if !defined(pal_lld_writeport) || defined(__DOXYGEN__) 419 #define palWritePort(port, bits) ((void)(port), (void)(bits)) 421 #define palWritePort(port, bits) pal_lld_writeport(port, bits) 437 #if !defined(pal_lld_setport) || defined(__DOXYGEN__) 438 #define palSetPort(port, bits) \ 439 palWritePort(port, palReadLatch(port) | (bits)) 441 #define palSetPort(port, bits) pal_lld_setport(port, bits) 457 #if !defined(pal_lld_clearport) || defined(__DOXYGEN__) 458 #define palClearPort(port, bits) \ 459 palWritePort(port, palReadLatch(port) & ~(bits)) 461 #define palClearPort(port, bits) pal_lld_clearport(port, bits) 477 #if !defined(pal_lld_toggleport) || defined(__DOXYGEN__) 478 #define palTogglePort(port, bits) \ 479 palWritePort(port, palReadLatch(port) ^ (bits)) 481 #define palTogglePort(port, bits) pal_lld_toggleport(port, bits) 496 #if !defined(pal_lld_readgroup) || defined(__DOXYGEN__) 497 #define palReadGroup(port, mask, offset) \ 498 ((palReadPort(port) >> (offset)) & (mask)) 500 #define palReadGroup(port, mask, offset) pal_lld_readgroup(port, mask, offset) 520 #if !defined(pal_lld_writegroup) || defined(__DOXYGEN__) 521 #define palWriteGroup(port, mask, offset, bits) \ 522 palWritePort(port, (palReadLatch(port) & ~((mask) << (offset))) | \ 523 (((bits) & (mask)) << (offset))) 525 #define palWriteGroup(port, mask, offset, bits) \ 526 pal_lld_writegroup(port, mask, offset, bits) 547 #if !defined(pal_lld_setgroupmode) || defined(__DOXYGEN__) 548 #define palSetGroupMode(port, mask, offset, mode) 550 #define palSetGroupMode(port, mask, offset, mode) \ 551 pal_lld_setgroupmode(port, mask, offset, mode) 566 #if !defined(pal_lld_readpad) || defined(__DOXYGEN__) 567 #define palReadPad(port, pad) ((palReadPort(port) >> (pad)) & 1U) 569 #define palReadPad(port, pad) pal_lld_readpad(port, pad) 587 #if !defined(pal_lld_writepad) || defined(__DOXYGEN__) 588 #define palWritePad(port, pad, bit) \ 589 palWritePort(port, (palReadLatch(port) & ~PAL_PORT_BIT(pad)) | \ 590 (((bit) & 1U) << pad)) 592 #define palWritePad(port, pad, bit) pal_lld_writepad(port, pad, bit) 608 #if !defined(pal_lld_setpad) || defined(__DOXYGEN__) 609 #define palSetPad(port, pad) palSetPort(port, PAL_PORT_BIT(pad)) 611 #define palSetPad(port, pad) pal_lld_setpad(port, pad) 627 #if !defined(pal_lld_clearpad) || defined(__DOXYGEN__) 628 #define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad)) 630 #define palClearPad(port, pad) pal_lld_clearpad(port, pad) 646 #if !defined(pal_lld_togglepad) || defined(__DOXYGEN__) 647 #define palTogglePad(port, pad) palTogglePort(port, PAL_PORT_BIT(pad)) 649 #define palTogglePad(port, pad) pal_lld_togglepad(port, pad) 668 #if !defined(pal_lld_setpadmode) || defined(__DOXYGEN__) 669 #define palSetPadMode(port, pad, mode) \ 670 palSetGroupMode(port, PAL_PORT_BIT(pad), 0U, mode) 672 #define palSetPadMode(port, pad, mode) pal_lld_setpadmode(port, pad, mode) 686 #if !defined(pal_lld_readline) || defined(__DOXYGEN__) 687 #define palReadLine(line) palReadPad(PAL_PORT(line), PAL_PAD(line)) 689 #define palReadLine(line) pal_lld_readline(line) 706 #if !defined(pal_lld_writeline) || defined(__DOXYGEN__) 707 #define palWriteLine(line, bit) palWritePad(PAL_PORT(line), PAL_PAD(line), bit) 709 #define palWriteLine(line, bit) pal_lld_writeline(line, bit) 724 #if !defined(pal_lld_setline) || defined(__DOXYGEN__) 725 #define palSetLine(line) palSetPad(PAL_PORT(line), PAL_PAD(line)) 727 #define palSetLine(line) pal_lld_setline(line) 742 #if !defined(pal_lld_clearline) || defined(__DOXYGEN__) 743 #define palClearLine(line) palClearPad(PAL_PORT(line), PAL_PAD(line)) 745 #define palClearLine(line) pal_lld_clearline(line) 760 #if !defined(pal_lld_toggleline) || defined(__DOXYGEN__) 761 #define palToggleLine(line) palTogglePad(PAL_PORT(line), PAL_PAD(line)) 763 #define palToggleLine(line) pal_lld_toggleline(line) 779 #if !defined(pal_lld_setlinemode) || defined(__DOXYGEN__) 780 #define palSetLineMode(line, mode) \ 781 palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode) 783 #define palSetLineMode(line, mode) pal_lld_setlinemode(line, mode) 786 #if (PAL_USE_CALLBACKS == TRUE) || (PAL_USE_WAIT == TRUE) || \ 798 #if !defined(pal_lld_enablepadevent) || defined(__DOXYGEN__) 799 #define palEnablePadEventI(port, pad, mode) 801 #define palEnablePadEventI(port, pad, mode) \ 802 pal_lld_enablepadevent(port, pad, mode) 814 #if !defined(pal_lld_disablepadevent) || defined(__DOXYGEN__) 815 #define palDisablePadEventI(port, pad) 817 #define palDisablePadEventI(port, pad) \ 818 pal_lld_disablepadevent(port, pad) 831 #define palEnablePadEvent(port, pad, mode) \ 834 palEnablePadEventI(port, pad, mode); \ 847 #define palDisablePadEvent(port, pad) \ 850 palDisablePadEventI(port, pad); \ 863 #if !defined(pal_lld_enablelineevent) || defined(__DOXYGEN__) 864 #define palEnableLineEventI(line, mode) \ 865 palEnablePadEventI(PAL_PORT(line), PAL_PAD(line), mode) 867 #define palEnableLineEventI(line, mode) \ 868 pal_lld_enablelineevent(line, mode) 879 #if !defined(pal_lld_disablelineevent) || defined(__DOXYGEN__) 880 #define palDisableLineEventI(line) \ 881 palDisablePadEventI(PAL_PORT(line), PAL_PAD(line)) 883 #define palDisableLineEventI(line) pal_lld_disablelineevent(line) 895 #define palEnableLineEvent(line, mode) \ 898 palEnableLineEventI(line, mode); \ 910 #define palDisableLineEvent(line) \ 913 palDisableLineEventI(line); \ 919 #if (PAL_USE_CALLBACKS == TRUE) || defined(__DOXYGEN__) 930 #define palSetPadCallback(port, pad, cb, arg) \ 933 palSetPadCallbackI(port, pad, cb, arg); \ 946 #define palSetLineCallback(line, cb, arg) \ 949 palSetLineCallbackI(line, cb, arg); \ 966 #if (PAL_USE_CALLBACKS == TRUE) || defined(__DOXYGEN__) 971 #if (PAL_USE_WAIT == TRUE) || defined(__DOXYGEN__) ioportmask_t mask
Bus mask aligned to port bit 0.
Type of a PAL event record.
uint32_t ioportmask_t
Digital I/O port sized unsigned type.
uint32_t iopadid_t
Type of an pad identifier.
palcallback_t cb
Event callback.
uint32_t ioline_t
Type of an I/O line.
ioportid_t portid
Port identifier.
msg_t palWaitLineTimeout(ioline_t line, sysinterval_t timeout)
Waits for an edge on the specified line.
msg_t palWaitPadTimeout(ioportid_t port, iopadid_t pad, sysinterval_t timeout)
Waits for an edge on the specified port/pad.
int32_t msg_t
Type of a message.
ioportmask_t palReadBus(const IOBus *bus)
Read from an I/O bus.
uint32_t ioportid_t
Port Identifier.
void palSetLineCallbackI(ioline_t line, palcallback_t cb, void *arg)
Associates a callback to a line.
uint_fast8_t offset
Offset, within the port, of the least significant bit of the bus.
msg_t palWaitPadTimeoutS(ioportid_t port, iopadid_t pad, sysinterval_t timeout)
Waits for an edge on the specified port/pad.
void * arg
Event callback argument.
uint32_t sysinterval_t
Type of system time interval.
void palSetPadCallbackI(ioportid_t port, iopadid_t pad, palcallback_t cb, void *arg)
Associates a callback to a port/pad.
void palWriteBus(const IOBus *bus, ioportmask_t bits)
Write to an I/O bus.
msg_t palWaitLineTimeoutS(ioline_t line, sysinterval_t timeout)
Waits for an edge on the specified line.
void palSetBusMode(const IOBus *bus, iomode_t mode)
Programs a bus with the specified mode.
uint32_t iomode_t
Digital I/O modes.
PLATFORM PAL subsystem low level driver header.
threads_queue_t threads
Threads queued for an event.
void(* palcallback_t)(void *arg)
Type of a PAL event callback.