VT backend.
More...
VT backend.
Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA integrated circuit in a product or a software update for such product, must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- This software, with or without modification, must only be used with a Nordic Semiconductor ASA integrated circuit.
- Any software provided in binary form under this license must not be reverse engineered, decompiled, modified and/or disassembled.
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
◆ NRF_VT_PIN_DISCONNECTED
#define NRF_VT_PIN_DISCONNECTED (0) |
Value used to indicate that an RX/TX pin should not be used
◆ nrf_vt_backend_init()
Function for initializing the VT backend.
This function configures and enables the SAADC and PWM using the provided configuration.
- Parameters
-
[in] | p_config | Pointer to the module initialization structure. |
- Return values
-
NRF_SUCCESS | If the initialization was successful. |
NRF_ERROR_INVALID_PARAM | If the module is passed invalid parameters in the configuration structure. |
NRF_ERROR_INVALID_STATE | If the PWM or SAADC drivers detect a reinitialization. |
NRF_ERROR_BUSY | If the PPI or SAADC channels are already in use. |
◆ nrf_vt_backend_rx_start()
uint32_t nrf_vt_backend_rx_start |
( |
void |
| ) |
|
Function for starting the VT backend RX.
This function starts (background) sampling on the SAADC.
- Return values
-
NRF_ERROR_SUCCESS | If the sampling was successfully started. |
NRF_ERROR_BUSY | If the sampling is already running. |
◆ nrf_vt_backend_rx_started()
bool nrf_vt_backend_rx_started |
( |
void |
| ) |
|
Function for checking if the VT backend RX is running.
- Return values
-
true | if the SAADC is sampling, false otherwise |
◆ nrf_vt_backend_rx_stop()
void nrf_vt_backend_rx_stop |
( |
void |
| ) |
|
Function for stopping the VT backend RX.
This function stops the background sampling on the SAADC. The SAADC will return whatever samples were made before stopping, so there may be some data left to process.
◆ nrf_vt_backend_tx_buffer_clear()
void nrf_vt_backend_tx_buffer_clear |
( |
void |
| ) |
|
Function for clearing the TX buffer.
This function will empty the PWM sequence buffer.
◆ nrf_vt_backend_tx_buffer_write_cast_frame()
uint32_t nrf_vt_backend_tx_buffer_write_cast_frame |
( |
uint8_t |
cast_no, |
|
|
const uint8_t const * |
p_data |
|
) |
| |
Function for writing a data frame to the TX buffer using a frame cast.
This function will use the supplied frame cast to write a series of values representing the data frame to the PWM sequence buffer. It will run faster than using nrf_vt_backend_tx_buffer_write_frame. To flush the sequence buffer onto the serial line, use nrf_vt_backend_tx_start.
- Parameters
-
[in] | cast_no | The index of the cast to use for frame construction. |
[in] | p_data | Pointer to the payload data. |
- Return values
-
NRF_SUCCESS | If the frame was successfully written to the PWM sequence buffer. |
NRF_ERROR_NO_MEM | If there was not enough space in the PWM sequence buffer to write the frame. |
NRF_ERROR_BUSY | If the PWM is currently transmitting the PWM sequence buffer. |
◆ nrf_vt_backend_tx_buffer_write_frame()
uint32_t nrf_vt_backend_tx_buffer_write_frame |
( |
const uint8_t const * |
p_data, |
|
|
uint32_t |
bits |
|
) |
| |
Function for writing a data frame to the TX buffer.
This function will write a series of values representing the data frame to the PWM sequence buffer. It will run a bit slower than using nrf_vt_backend_tx_buffer_write_cast_frame due to more copy operations. To flush the sequence buffer onto the serial line, use nrf_vt_backend_tx_start.
- Parameters
-
[in] | p_data | Pointer to the payload data. |
[in] | bits | Amount of bits in the payload data. |
- Return values
-
NRF_SUCCESS | If the frame was successfully written to the PWM sequence buffer. |
NRF_ERROR_NO_MEM | If there was not enough space in the PWM sequence buffer to write the frame. |
NRF_ERROR_BUSY | If the PWM is currently transmitting the PWM sequence buffer. |
◆ nrf_vt_backend_tx_frame_cast_init()
uint32_t nrf_vt_backend_tx_frame_cast_init |
( |
uint8_t |
cast_no, |
|
|
uint32_t |
payload_bits |
|
) |
| |
Function for initializing a frame cast.
This function sets up a 'frame cast' for more efficient PWM sequence construction. The cast will be pre-filled with start and stop bits so that only the payload bits need to be copied on construction.
- Parameters
-
[in] | cast_no | The index of the cast to initialize. |
[in] | payload_bits | The amount payload length in bits for the frame type this cast is used for. |
- Return values
-
NRF_SUCCESS | If the initialization was successful. |
NRF_ERROR_INVALID_PARAM | If an invalid cast index or payload length was supplied. |
◆ nrf_vt_backend_tx_start()
uint32_t nrf_vt_backend_tx_start |
( |
void |
| ) |
|
Function for starting transmission of the TX buffer.
This function will start flushing the PWM sequence buffer onto the serial line using PWM. The function returns immediately and the PWM activity will run in the background until all the data has been flushed.
- Return values
-
NRF_SUCCCESS | If the PWM sequence was started successfully. |
NRF_ERROR_BUSY | If the PWM is already transmitting. |
◆ nrf_vt_backend_tx_started()
bool nrf_vt_backend_tx_started |
( |
void |
| ) |
|
Function for checking if the VT backend TX is running.
- Return values
-
true | if the PWM is playing a sequence, false otherwise |
◆ nrf_vt_backend_uninit()
void nrf_vt_backend_uninit |
( |
void |
| ) |
|
Function for uninitializing the VT backend.
This function resets the configuration in the SAADC and PWM and the module itself.