123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- #ifndef NRFX_UARTE_H__
- #define NRFX_UARTE_H__
- #include <nrfx.h>
- #include <hal/nrf_uarte.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef struct
- {
- NRF_UARTE_Type * p_reg;
- uint8_t drv_inst_idx;
- } nrfx_uarte_t;
- #ifndef __NRFX_DOXYGEN__
- enum {
- #if NRFX_CHECK(NRFX_UARTE0_ENABLED)
- NRFX_UARTE0_INST_IDX,
- #endif
- #if NRFX_CHECK(NRFX_UARTE1_ENABLED)
- NRFX_UARTE1_INST_IDX,
- #endif
- #if NRFX_CHECK(NRFX_UARTE2_ENABLED)
- NRFX_UARTE2_INST_IDX,
- #endif
- #if NRFX_CHECK(NRFX_UARTE3_ENABLED)
- NRFX_UARTE3_INST_IDX,
- #endif
- NRFX_UARTE_ENABLED_COUNT
- };
- #endif
- #define NRFX_UARTE_INSTANCE(id) \
- { \
- .p_reg = NRFX_CONCAT_2(NRF_UARTE, id), \
- .drv_inst_idx = NRFX_CONCAT_3(NRFX_UARTE, id, _INST_IDX), \
- }
- typedef enum
- {
- NRFX_UARTE_EVT_TX_DONE,
- NRFX_UARTE_EVT_RX_DONE,
- NRFX_UARTE_EVT_ERROR,
- } nrfx_uarte_evt_type_t;
- typedef struct
- {
- uint32_t pseltxd;
- uint32_t pselrxd;
- uint32_t pselcts;
- uint32_t pselrts;
- void * p_context;
- nrf_uarte_hwfc_t hwfc;
- nrf_uarte_parity_t parity;
- nrf_uarte_baudrate_t baudrate;
- uint8_t interrupt_priority;
- } nrfx_uarte_config_t;
- #define NRFX_UARTE_DEFAULT_CONFIG \
- { \
- .pseltxd = NRF_UARTE_PSEL_DISCONNECTED, \
- .pselrxd = NRF_UARTE_PSEL_DISCONNECTED, \
- .pselcts = NRF_UARTE_PSEL_DISCONNECTED, \
- .pselrts = NRF_UARTE_PSEL_DISCONNECTED, \
- .p_context = NULL, \
- .hwfc = (nrf_uarte_hwfc_t)NRFX_UARTE_DEFAULT_CONFIG_HWFC, \
- .parity = (nrf_uarte_parity_t)NRFX_UARTE_DEFAULT_CONFIG_PARITY, \
- .baudrate = (nrf_uarte_baudrate_t)NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE, \
- .interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY, \
- }
- typedef struct
- {
- uint8_t * p_data;
- size_t bytes;
- } nrfx_uarte_xfer_evt_t;
- typedef struct
- {
- nrfx_uarte_xfer_evt_t rxtx;
- uint32_t error_mask;
- } nrfx_uarte_error_evt_t;
- typedef struct
- {
- nrfx_uarte_evt_type_t type;
- union
- {
- nrfx_uarte_xfer_evt_t rxtx;
- nrfx_uarte_error_evt_t error;
- } data;
- } nrfx_uarte_event_t;
- typedef void (*nrfx_uarte_event_handler_t)(nrfx_uarte_event_t const * p_event,
- void * p_context);
- nrfx_err_t nrfx_uarte_init(nrfx_uarte_t const * p_instance,
- nrfx_uarte_config_t const * p_config,
- nrfx_uarte_event_handler_t event_handler);
- void nrfx_uarte_uninit(nrfx_uarte_t const * p_instance);
- __STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_task_t task);
- __STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_event_t event);
- nrfx_err_t nrfx_uarte_tx(nrfx_uarte_t const * p_instance,
- uint8_t const * p_data,
- size_t length);
- bool nrfx_uarte_tx_in_progress(nrfx_uarte_t const * p_instance);
- void nrfx_uarte_tx_abort(nrfx_uarte_t const * p_instance);
- nrfx_err_t nrfx_uarte_rx(nrfx_uarte_t const * p_instance,
- uint8_t * p_data,
- size_t length);
- bool nrfx_uarte_rx_ready(nrfx_uarte_t const * p_instance);
- void nrfx_uarte_rx_abort(nrfx_uarte_t const * p_instance);
- uint32_t nrfx_uarte_errorsrc_get(nrfx_uarte_t const * p_instance);
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- __STATIC_INLINE uint32_t nrfx_uarte_task_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_task_t task)
- {
- return nrf_uarte_task_address_get(p_instance->p_reg, task);
- }
- __STATIC_INLINE uint32_t nrfx_uarte_event_address_get(nrfx_uarte_t const * p_instance,
- nrf_uarte_event_t event)
- {
- return nrf_uarte_event_address_get(p_instance->p_reg, event);
- }
- #endif
- void nrfx_uarte_0_irq_handler(void);
- void nrfx_uarte_1_irq_handler(void);
- void nrfx_uarte_2_irq_handler(void);
- void nrfx_uarte_3_irq_handler(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|