2016-11-17 22:53:10 +01:00
|
|
|
/*
|
2018-08-17 15:48:03 +02:00
|
|
|
* Copyright (C) 2015-2018 Freie Universität Berlin
|
2020-05-03 15:54:32 +02:00
|
|
|
* 2020 Philipp-Alexander Blum <philipp-blum@jakiku.de>
|
2016-11-17 22:53:10 +01:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup cpu_nrf52
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief nRF52 specific definitions for handling peripherals
|
|
|
|
*
|
2017-01-19 21:45:23 +01:00
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
2020-05-03 15:54:32 +02:00
|
|
|
* @author Philipp-Alexander Blum <philipp-blum@jakiku.de>
|
2016-11-17 22:53:10 +01:00
|
|
|
*/
|
|
|
|
|
2017-05-23 18:19:52 +02:00
|
|
|
#ifndef PERIPH_CPU_H
|
|
|
|
#define PERIPH_CPU_H
|
2016-11-17 22:53:10 +01:00
|
|
|
|
|
|
|
#include "periph_cpu_common.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-08-29 17:28:10 +02:00
|
|
|
/**
|
|
|
|
* @brief System core clock speed, fixed to 64MHz for all NRF52x CPUs
|
|
|
|
*/
|
|
|
|
#define CLOCK_CORECLOCK (64000000U)
|
|
|
|
|
2018-08-17 15:48:03 +02:00
|
|
|
/**
|
|
|
|
* @name Peripheral clock speed (fixed to 16MHz for nRF52 based CPUs)
|
|
|
|
*/
|
|
|
|
#define PERIPH_CLOCK (16000000U)
|
|
|
|
|
2017-10-09 15:30:50 +02:00
|
|
|
/**
|
|
|
|
* @brief The nRF52 family of CPUs provides a fixed number of 9 ADC lines
|
|
|
|
*/
|
2021-02-10 17:20:01 +01:00
|
|
|
#ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
|
|
|
|
#define ADC_NUMOF (10U)
|
|
|
|
#else
|
2017-10-09 15:30:50 +02:00
|
|
|
#define ADC_NUMOF (9U)
|
2021-02-10 17:20:01 +01:00
|
|
|
#endif
|
2017-10-09 15:30:50 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief nRF52 specific naming of ADC lines (for convenience)
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
NRF52_AIN0 = 0, /**< Analog Input 0 */
|
|
|
|
NRF52_AIN1 = 1, /**< Analog Input 1 */
|
|
|
|
NRF52_AIN2 = 2, /**< Analog Input 2 */
|
|
|
|
NRF52_AIN3 = 3, /**< Analog Input 3 */
|
|
|
|
NRF52_AIN4 = 4, /**< Analog Input 4 */
|
|
|
|
NRF52_AIN5 = 5, /**< Analog Input 5 */
|
|
|
|
NRF52_AIN6 = 6, /**< Analog Input 6 */
|
|
|
|
NRF52_AIN7 = 7, /**< Analog Input 7 */
|
|
|
|
NRF52_VDD = 8, /**< VDD, not useful if VDD is reference... */
|
2021-02-10 17:20:01 +01:00
|
|
|
#ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
|
|
|
|
NRF52_VDDHDIV5 = 9, /**< VDDH divided by 5 */
|
|
|
|
#endif
|
2017-10-09 15:30:50 +02:00
|
|
|
};
|
|
|
|
|
2019-02-07 08:06:58 +01:00
|
|
|
#ifndef DOXYGEN
|
2017-08-25 13:27:00 +02:00
|
|
|
/**
|
|
|
|
* @brief Override ADC resolution values
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define HAVE_ADC_RES_T
|
|
|
|
typedef enum {
|
|
|
|
ADC_RES_6BIT = 0xf0, /**< not supported by hardware */
|
|
|
|
ADC_RES_8BIT = 0x00, /**< ADC resolution: 8 bit */
|
|
|
|
ADC_RES_10BIT = 0x01, /**< ADC resolution: 10 bit */
|
|
|
|
ADC_RES_12BIT = 0x02, /**< ADC resolution: 12 bit */
|
2017-10-09 15:30:50 +02:00
|
|
|
ADC_RES_14BIT = 0xf1, /**< supported with oversampling, not implemented */
|
2017-08-25 13:27:00 +02:00
|
|
|
ADC_RES_16BIT = 0xf2 /**< not supported by hardware */
|
|
|
|
} adc_res_t;
|
|
|
|
/** @} */
|
2019-02-07 08:06:58 +01:00
|
|
|
#endif /* ndef DOXYGEN */
|
2017-08-25 13:27:00 +02:00
|
|
|
|
2021-02-25 14:26:18 +01:00
|
|
|
/**
|
|
|
|
* @brief Size of the UART TX buffer for non-blocking mode.
|
|
|
|
*/
|
|
|
|
#ifndef UART_TXBUF_SIZE
|
|
|
|
#define UART_TXBUF_SIZE (64)
|
|
|
|
#endif
|
|
|
|
|
2020-05-18 19:14:56 +02:00
|
|
|
/**
|
|
|
|
* @brief Common SPI/I2C interrupt callback
|
|
|
|
*
|
|
|
|
* @param arg Opaque context pointer
|
|
|
|
*/
|
|
|
|
typedef void (*spi_twi_irq_cb_t)(void *arg);
|
|
|
|
|
|
|
|
/**
|
2023-05-01 21:16:11 +02:00
|
|
|
* @brief Register a SPI IRQ handler for a shared I2C/SPI irq vector
|
2020-05-18 19:14:56 +02:00
|
|
|
*
|
|
|
|
* @param bus bus to register the IRQ handler on
|
|
|
|
* @param cb callback to call on IRQ
|
|
|
|
* @param arg Argument to pass to the handler
|
|
|
|
*/
|
|
|
|
void spi_twi_irq_register_spi(NRF_SPIM_Type *bus,
|
|
|
|
spi_twi_irq_cb_t cb, void *arg);
|
|
|
|
|
|
|
|
/**
|
2023-05-01 21:16:11 +02:00
|
|
|
* @brief Register a I2C IRQ handler for a shared I2C/SPI irq vector
|
2020-05-18 19:14:56 +02:00
|
|
|
*
|
|
|
|
* @param bus bus to register the IRQ handler on
|
|
|
|
* @param cb callback to call on IRQ
|
|
|
|
* @param arg Argument to pass to the handler
|
|
|
|
*/
|
|
|
|
void spi_twi_irq_register_i2c(NRF_TWIM_Type *bus,
|
|
|
|
spi_twi_irq_cb_t cb, void *arg);
|
2021-10-26 19:44:17 +02:00
|
|
|
|
2022-08-19 15:18:41 +02:00
|
|
|
/**
|
|
|
|
* @brief Acquire the shared I2C/SPI peripheral in I2C mode
|
|
|
|
*
|
|
|
|
* @param bus bus to acquire exclusive access on
|
2022-08-19 15:32:09 +02:00
|
|
|
* @param cb ISR handler to call on IRQ
|
|
|
|
* @param arg ISR handler argument
|
2022-08-19 15:18:41 +02:00
|
|
|
*/
|
2022-08-19 15:32:09 +02:00
|
|
|
void nrf5x_i2c_acquire(NRF_TWIM_Type *bus, spi_twi_irq_cb_t cb, void *arg);
|
2022-08-19 15:18:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Release the shared I2C/SPI peripheral in I2C mode
|
|
|
|
*
|
|
|
|
* @param bus bus to release exclusive access on
|
|
|
|
*/
|
|
|
|
void nrf5x_i2c_release(NRF_TWIM_Type *bus);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Acquire the shared I2C/SPI peripheral in SPI mode
|
|
|
|
*
|
2022-08-19 15:32:09 +02:00
|
|
|
* @param bus bus to release exclusive access on
|
|
|
|
* @param cb ISR handler to call on IRQ
|
|
|
|
* @param arg ISR handler argument
|
2022-08-19 15:18:41 +02:00
|
|
|
*/
|
2022-08-19 15:32:09 +02:00
|
|
|
void nrf5x_spi_acquire(NRF_SPIM_Type *bus, spi_twi_irq_cb_t cb, void *arg);
|
2022-08-19 15:18:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Acquire the shared I2C/SPI peripheral in SPI mode
|
|
|
|
*
|
|
|
|
* @param bus bus to release exclusive access on
|
|
|
|
*/
|
2022-08-19 15:32:09 +02:00
|
|
|
void nrf5x_spi_release(NRF_SPIM_Type *bus);
|
2022-08-19 15:18:41 +02:00
|
|
|
|
2016-11-17 22:53:10 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-23 18:19:52 +02:00
|
|
|
#endif /* PERIPH_CPU_H */
|
2016-11-17 22:53:10 +01:00
|
|
|
/** @} */
|