nrfxlib API 3.3.99
Loading...
Searching...
No Matches
nrf_scan.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef NRF_SCAN_H__
8#define NRF_SCAN_H__
9
10#include <stdbool.h>
11#include <stdint.h>
12// #include "nrf_config_scan.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
46
57
74
84
86typedef void (* nrf_scan_event_handler_t)(nrf_scan_event_type_t const * p_event,
87 void * p_context);
88
92typedef struct
93{
94 uint16_t sp_identifier;
95 uint16_t
98
102typedef struct
103{
104 uint16_t sjw;
105 uint16_t prop_seg;
106 uint16_t phase_seg1;
107 uint16_t phase_seg2;
108 uint16_t prescaler;
110
114typedef struct
115{
116 uint32_t identifier;
117 uint8_t data_length;
118 uint8_t ide;
119 uint8_t rtr;
120 uint8_t data[8];
122
126typedef struct
127{
128 uint32_t id;
129 uint32_t mask;
131
141
149
153typedef struct
154{
155 void * p_reg;
156 uint8_t
158} nrf_scan_t;
159
168
177
196 void * p_context);
197
209void nrf_scan_uninit(nrf_scan_t const * p_scan);
210
222
235
255 nrf_scan_timing_t const * p_timing);
256
270
285 nrf_scan_rx_filter_t const * p_rxfilter,
286 uint8_t index);
287
303
319
334
351 nrf_scan_frame_t * p_tx_frame);
352
372
377
380#ifdef __cplusplus
381}
382#endif
383
384#endif // NRF_SCAN_H__
nrf_scan_error_t nrf_scan_disable_rx_filter(nrf_scan_t const *p_scan, uint8_t index)
Disable a sCAN RX filter.
nrf_scan_error_t nrf_scan_init(nrf_scan_t const *p_scan, nrf_scan_event_handler_t handler, void *p_context)
Initialize the sCAN driver for a given instance.
nrf_scan_error_t nrf_scan_unlock_rx_mailbox(nrf_scan_t const *p_scan, uint8_t index)
Unlock sCAN RX mailbox[index].
nrf_scan_error_t nrf_scan_send(nrf_scan_t const *p_scan, nrf_scan_frame_t *p_tx_frame)
sCAN send function.
nrf_scan_error_t
sCAN error code definitions
Definition nrf_scan.h:60
@ NRF_SCAN_ERROR_BIT1_ERROR
TX. Node can't send recessive bit.
Definition nrf_scan.h:65
@ NRF_SCAN_ERROR_PROTOCOL
Generic error response.
Definition nrf_scan.h:62
@ NRF_SCAN_SUCCESS
Definition nrf_scan.h:61
@ NRF_SCAN_ERROR_ACK_ERROR
TX. Node transmits message but ACK slot is not made dominant by receivers.
Definition nrf_scan.h:67
@ NRF_SCAN_ERROR_FORM_ERROR
RX. Node receives an invalid value in a bit that belongs to SOF/EOF fields or ACK/CRC delimiters.
Definition nrf_scan.h:66
@ NRF_SCAN_ERROR_BUSY
API level error. sCAN is busy.
Definition nrf_scan.h:69
@ NRF_SCAN_ERROR_BIT_STUFFING_ERROR
RX. Node receives 6 consecutive dominant/recessive bits between SOF and CRC.
Definition nrf_scan.h:63
@ NRF_SCAN_ERROR_INVALID_STATE
API level error. nrfx driver in invalid state.
Definition nrf_scan.h:72
@ NRF_SCAN_ERROR_UNSUPPORTED
API level error. Config parameter combination is not supported.
Definition nrf_scan.h:70
@ NRF_SCAN_ERROR_BIT0_ERROR
TX. Node can't send dominant bit.
Definition nrf_scan.h:64
@ NRF_SCAN_ERROR_CRC_ERROR
RX. Node calculates message CRC that differs from the one sent.
Definition nrf_scan.h:68
@ NRF_SCAN_ERROR_INVALID_PARAM
API level error. Invalid config parameter.
Definition nrf_scan.h:71
nrf_scan_error_t nrf_scan_mode(nrf_scan_t const *p_scan, nrf_scan_mode_type_t *p_mode)
Configure sCAN mode.
nrf_scan_error_t nrf_scan_disable(nrf_scan_t const *p_scan)
Explicitly power down the controller.
nrf_scan_rx_mailbox_t m_scan_rx_mailbox[]
sCAN RX mailbox.
void(* nrf_scan_event_handler_t)(nrf_scan_event_type_t const *p_event, void *p_context)
sCAN event handler function pointer
Definition nrf_scan.h:86
void nrf_scan_uninit(nrf_scan_t const *p_scan)
Uninitialize the sCAN driver instance.
nrf_scan_status_t nrf_scan_get_status(nrf_scan_t const *p_scan)
Get sCAN state and errors.
nrf_scan_error_t nrf_scan_set_rx_filter(nrf_scan_t const *p_scan, nrf_scan_rx_filter_t const *p_rxfilter, uint8_t index)
Configure a sCAN RX filter.
nrf_scan_error_t nrf_scan_abort(nrf_scan_t const *p_scan)
Abort any ongoing sCAN operation.
nrf_scan_error_t nrf_scan_enable_rx_filter(nrf_scan_t const *p_scan, uint8_t index)
Enable a sCAN RX filter.
nrf_scan_state_t
sCAN state definitions
Definition nrf_scan.h:77
@ NRF_SCAN_STATE_ERROR_WARNING
TEC/REC < 128.
Definition nrf_scan.h:79
@ NRF_SCAN_STATE_ERROR_PASSIVE
TEC/REC < 256.
Definition nrf_scan.h:80
@ NRF_SCAN_STATE_STOPPED
No participation in CAN communication.
Definition nrf_scan.h:82
@ NRF_SCAN_STATE_ERROR_ACTIVE
TEC/REC < 96.
Definition nrf_scan.h:78
@ NRF_SCAN_STATE_BUS_OFF
TEC/REC >= 256.
Definition nrf_scan.h:81
nrf_scan_error_t nrf_scan_enable(nrf_scan_t const *p_scan)
Explicitly power up and configure the controller.
void nrf_scan_irq_handler(void)
IRQ handler to be called from the sCAN interrupt vector.
nrf_scan_event_type_t
sCAN event definitions
Definition nrf_scan.h:40
@ NRF_SCAN_EVT_RX_COMPLETE
RX has finished after an ID match.
Definition nrf_scan.h:42
@ NRF_SCAN_EVT_TX_COMPLETE
TX has finished, if mode is ONESHOT this happens even if there are errors or arbitration was lost.
Definition nrf_scan.h:41
@ NRF_SCAN_EVT_ERROR
sCAN has detected an error
Definition nrf_scan.h:43
@ NRF_SCAN_EVT_STATE_CHANGED
sCAN state has changed
Definition nrf_scan.h:44
nrf_scan_error_t nrf_scan_timing(nrf_scan_t const *p_scan, nrf_scan_timing_t const *p_timing)
Configure sCAN timing.
nrf_scan_mode_type_t
sCAN operation mode definitions
Definition nrf_scan.h:49
@ NRF_SCAN_MODE_LOOPBACK
To test API, moves TX data to RX data via SW.
Definition nrf_scan.h:51
@ NRF_SCAN_MODE_NORMAL
Normal mode of operation, RX/TX, uses ID filters, TX will be attemted until success.
Definition nrf_scan.h:50
@ NRF_SCAN_MODE_ONESHOT
Definition nrf_scan.h:54
@ NRF_SCAN_MODE_LISTENONLY
Definition nrf_scan.h:52
uint16_t last_updated_mailbox
index corresponding to the last updated mailbox, populated when NRF_SCAN_EVT_RX_COMPLETE happens
Definition nrf_scan.h:96
uint16_t sp_identifier
Soft peripheral identifier.
Definition nrf_scan.h:94
sCAN context structure. ,
Definition nrf_scan.h:93
uint8_t data_length
Data length in bytes [0,8].
Definition nrf_scan.h:117
uint32_t identifier
ID, 11 or 29 bits depending on ide.
Definition nrf_scan.h:116
uint8_t rtr
Remote Transmission Request bit.
Definition nrf_scan.h:119
uint8_t ide
Identifier Extension bit.
Definition nrf_scan.h:118
sCAN TX/RX frame structure. ,
Definition nrf_scan.h:115
uint32_t mask
Filter mask.
Definition nrf_scan.h:129
uint32_t id
ID, can be standard or extended.
Definition nrf_scan.h:128
sCAN RX filter structure. ,
Definition nrf_scan.h:127
bool ready
Indicator for new data to be processed.
Definition nrf_scan.h:139
nrf_scan_frame_t rx_frame
Received frame.
Definition nrf_scan.h:137
nrf_scan_rx_filter_t rx_filter
Filter.
Definition nrf_scan.h:138
sCAN RX mailbox structure. ,
Definition nrf_scan.h:136
nrf_scan_state_t state
CAN controller state.
Definition nrf_scan.h:166
nrf_scan_error_t error
CAN errors.
Definition nrf_scan.h:165
sCAN status structure. ,
Definition nrf_scan.h:164
uint8_t drv_inst_idx
Index of the driver instance. For internal use only.
Definition nrf_scan.h:157
void * p_reg
Pointer to a structure with sCAN virtual register interface.
Definition nrf_scan.h:155
sCAN driver instance structure. ,
Definition nrf_scan.h:154
uint16_t phase_seg2
Phase segment 2 length in quanta units.
Definition nrf_scan.h:107
uint16_t prop_seg
Propagation segment length in quanta units.
Definition nrf_scan.h:105
uint16_t prescaler
Prescaler, number of clock cycles per quanta unit.
Definition nrf_scan.h:108
uint16_t phase_seg1
Phase segment 1 length in quanta units.
Definition nrf_scan.h:106
uint16_t sjw
(Re)synchronization jump width in quanta units
Definition nrf_scan.h:104
sCAN timing configuration structure. ,
Definition nrf_scan.h:103