1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/nrf5x_common/include/periph_cpu_common.h

115 lines
2.9 KiB
C
Raw Normal View History

2016-02-04 15:30:06 +01:00
/*
* Copyright (C) 2015-2016 Freie Universität Berlin
2016-02-04 15:30:06 +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_nrf5x_common
2016-02-04 15:30:06 +01:00
* @{
*
* @file
* @brief nRF5x common definitions for handling peripherals
2016-02-04 15:30:06 +01:00
*
* @author Hauke Petersen <hauke.peterse@fu-berlin.de>
*/
#ifndef PERIPH_CPU_COMMON_H_
#define PERIPH_CPU_COMMON_H_
2016-02-04 15:30:06 +01:00
#include "cpu.h"
#ifdef __cplusplus
extern "C" {
#endif
2016-02-07 12:56:27 +01:00
/**
* @brief Length of the CPU_ID in octets
*/
#define CPUID_LEN (8U)
/**
* @brief Override macro for defining GPIO pins
*
* The port definition is used (and zeroed) to suppress compiler warnings
*/
#define GPIO_PIN(x,y) ((x & 0) | y)
2016-02-04 15:30:06 +01:00
/**
2016-02-20 14:43:41 +01:00
* @brief Generate GPIO mode bitfields
*
* We use 4 bit to encode the pin mode:
* - bit 0: output enable
* - bit 1: input connect
* - bit 2+3: pull resistor configuration
*/
#define GPIO_MODE(oe, ic, pr) (oe | (ic << 1) | (pr << 2))
#ifndef DOXYGEN
2016-02-20 14:43:41 +01:00
/**
* @brief Override GPIO modes
*
* We use 4 bit to encode the pin mode:
* - bit 0: output enable
* - bit 1: input connect
* - bit 2+3: pull resistor configuration
2016-02-04 15:30:06 +01:00
* @{
*/
2016-02-20 14:43:41 +01:00
#define HAVE_GPIO_MODE_T
2016-02-04 15:30:06 +01:00
typedef enum {
2016-02-20 14:43:41 +01:00
GPIO_IN = GPIO_MODE(0, 0, 0), /**< IN */
GPIO_IN_PD = GPIO_MODE(0, 0, 1), /**< IN with pull-down */
GPIO_IN_PU = GPIO_MODE(0, 0, 3), /**< IN with pull-up */
GPIO_OUT = GPIO_MODE(1, 1, 0), /**< OUT (push-pull) */
GPIO_OD = (0xff), /**< not supported by HW */
GPIO_OD_PU = (0xfe) /**< not supported by HW */
} gpio_mode_t;
2016-02-04 15:30:06 +01:00
/** @} */
/**
* @brief Override GPIO active flank values
* @{
*/
#define HAVE_GPIO_FLANK_T
typedef enum {
GPIO_FALLING = 2, /**< emit interrupt on falling flank */
GPIO_RISING = 1, /**< emit interrupt on rising flank */
GPIO_BOTH = 3 /**< emit interrupt on both flanks */
} gpio_flank_t;
/** @} */
/**
* @brief Override ADC resolution values
* @{
*/
#define HAVE_ADC_RES_T
typedef enum {
ADC_RES_6BIT = 0xf0, /**< ADC resolution: 6 bit */
ADC_RES_8BIT = 0x00, /**< ADC resolution: 8 bit */
ADC_RES_10BIT = 0x02, /**< ADC resolution: 10 bit */
ADC_RES_12BIT = 0xf1, /**< ADC resolution: 12 bit */
ADC_RES_14BIT = 0xf2, /**< ADC resolution: 14 bit */
ADC_RES_16BIT = 0xf3 /**< ADC resolution: 16 bit */
} adc_res_t;
/** @} */
#endif /* ndef DOXYGEN */
/**
* @brief Timer configuration options
*/
typedef struct {
NRF_TIMER_Type *dev; /**< timer device */
uint8_t channels; /**< number of channels available */
uint8_t bitmode; /**< counter width */
uint8_t irqn; /**< IRQ number of the timer device */
} timer_conf_t;
2016-02-04 15:30:06 +01:00
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CPU_COMMON_H_ */
2016-02-04 15:30:06 +01:00
/** @} */