cc2538/include/periph_cpu.h File Reference

CPU specific definitions for internal peripheral handling. More...

Detailed Description

#include <stdint.h>
#include <stdio.h>
#include "cpu.h"
#include "periph/dev_enums.h"
+ Include dependency graph for cc2538/include/periph_cpu.h:

Go to the source code of this file.

Data Structures

struct  i2c_conf_t
 I2C configuration options. More...
 
struct  spi_clk_conf_t
 Datafields for static SPI clock configuration values. More...
 
struct  spi_conf_t
 SPI configuration data structure. More...
 
struct  timer_conf_t
 Timer configuration data. More...
 

Macros

#define GPIO_PIN(port, pin)
 Define a custom GPIO_PIN macro. More...
 
#define GPIO_UNDEF   99
 Define a custom GPIO_UNDEF value.
 
Internal GPIO shift and masking
#define PORTNUM_MASK   (0x00007000)
 bit mask for GPIO port [0-3]
 
#define PORTNUM_SHIFT   (12U)
 bit shift for GPIO port
 
#define PIN_MASK   (0x00000007)
 bit mask for GPIO pin [0-7]
 
#define GPIO_MASK   (0xfffff000)
 bit mask for GPIO port addr
 
#define PERIPH_SPI_NEEDS_INIT_CS
 declare needed generic SPI functions
 
#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
 
#define PERIPH_SPI_NEEDS_TRANSFER_REG
 
#define PERIPH_SPI_NEEDS_TRANSFER_REGS
 

Functions

static cc2538_gpio_tgpio (gpio_t pin)
 Access GPIO low-level device. More...
 
static uint8_t gpio_port_num (gpio_t pin)
 Helper function to get port number for gpio pin. More...
 
static uint8_t gpio_pin_num (gpio_t pin)
 Helper function to get pin number for gpio pin. More...
 
static uint32_t gpio_pin_mask (gpio_t pin)
 Helper function to get bit mask for gpio pin number. More...
 
static uint8_t gpio_pp_num (gpio_t pin)
 Helper function to get CC2538 gpio number from port and pin. More...
 
static void gpio_hw_ctrl (gpio_t pin)
 Helper function to enable gpio hardware control. More...
 
static void gpio_sw_ctrl (gpio_t pin)
 Helper function to enable gpio software control. More...
 
#define CPUID_ADDR   (&IEEE_ADDR_MSWORD)
 Starting offset of CPU_ID.
 
#define CPUID_LEN   (8U)
 Length of the CPU_ID in octets.
 
#define HAVE_GPIO_T
 Define a custom type for GPIO pins.
 
typedef uint32_t gpio_t
 
#define HAVE_GPIO_MODE_T
 Override the default GPIO mode settings.
 
enum  gpio_mode_t {
  GPIO_IN = ((uint8_t)0x00), GPIO_IN_PD = ((uint8_t)IOC_OVERRIDE_PDE), GPIO_IN_PU = ((uint8_t)IOC_OVERRIDE_PUE), GPIO_OUT = ((uint8_t)IOC_OVERRIDE_OE),
  GPIO_OD = (0xff), GPIO_OD_PU = (0xff), GPIO_IN = (IN), GPIO_IN_PD = (IN | PD),
  GPIO_IN_PU = (IN | PU), GPIO_OUT = (OUT), GPIO_OD = (OUT | OD), GPIO_OD_PU = (OUT | OD | PU),
  GPIO_IN, GPIO_IN_PD, GPIO_IN_PU, GPIO_OUT,
  GPIO_OD, GPIO_OD_PU
}
 
#define HAVE_SPI_MODE_T
 Override SPI mode settings.
 
#define HAVE_SPI_CLK_T
 @ More...
 
enum  spi_mode_t {
  SPI_MODE_0 = SPI_MODE_SEL(0, 0), SPI_MODE_1 = SPI_MODE_SEL(0, 1), SPI_MODE_2 = SPI_MODE_SEL(1, 0), SPI_MODE_3 = SPI_MODE_SEL(1, 1),
  SPI_MODE_0 = 0, SPI_MODE_1 = (SSI_CR0_SPH), SPI_MODE_2 = (SSI_CR0_SPO), SPI_MODE_3 = (SSI_CR0_SPO | SSI_CR0_SPH),
  SPI_MODE_0 = SSI_FRF_MOTO_MODE_0, SPI_MODE_1 = SSI_FRF_MOTO_MODE_1, SPI_MODE_2 = SSI_FRF_MOTO_MODE_2, SPI_MODE_3 = SSI_FRF_MOTO_MODE_0,
  SPI_MODE_0 = 0, SPI_MODE_1 = SPI_CONFIG_CPHA_Msk, SPI_MODE_2 = SPI_CONFIG_CPOL_Msk, SPI_MODE_3 = (SPI_CONFIG_CPOL_Msk | SPI_CONFIG_CPHA_Msk),
  SPI_MODE_0 = 0x0, SPI_MODE_1 = 0x1, SPI_MODE_2 = 0x2, SPI_MODE_3 = 0x3,
  SPI_MODE_0 = (SPI_CSR_NCPHA), SPI_MODE_1 = (0), SPI_MODE_2 = (SPI_CSR_CPOL | SPI_CSR_NCPHA), SPI_MODE_3 = (SPI_CSR_CPOL),
  SPI_MODE_0 = 0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3
}
 
enum  spi_clk_t {
  SPI_CLK_100KHZ = SPI_CLK_SEL(0, 1, 1), SPI_CLK_400KHZ = SPI_CLK_SEL(1, 1, 0), SPI_CLK_1MHZ = SPI_CLK_SEL(0, 0, 1), SPI_CLK_5MHZ = SPI_CLK_SEL(0, 0, 0),
  SPI_CLK_10MHZ = SPI_CLK_SEL(1, 0, 0), SPI_CLK_100KHZ = 0, SPI_CLK_400KHZ = 1, SPI_CLK_1MHZ = 2,
  SPI_CLK_5MHZ = 3, SPI_CLK_10MHZ = 4, SPI_CLK_100KHZ = 100000, SPI_CLK_400KHZ = 400000,
  SPI_CLK_1MHZ = 1000000, SPI_CLK_4MHZ = 4000000, SPI_CLK_5MHZ = 5000000, SPI_CLK_10MHZ = 10000000,
  SPI_CLK_100KHZ = 119, SPI_CLK_400KHZ = 29, SPI_CLK_1MHZ = 11, SPI_CLK_5MHZ = 2,
  SPI_CLK_10MHZ = 0, SPI_CLK_100KHZ = 100, SPI_CLK_400KHZ = 400, SPI_CLK_1MHZ = 1000,
  SPI_CLK_5MHZ = 5000, SPI_CLK_10MHZ = 10000, SPI_CLK_100KHZ = SPI_FREQUENCY_FREQUENCY_K125, SPI_CLK_400KHZ = SPI_FREQUENCY_FREQUENCY_K500,
  SPI_CLK_1MHZ = SPI_FREQUENCY_FREQUENCY_M1, SPI_CLK_5MHZ = SPI_FREQUENCY_FREQUENCY_M4, SPI_CLK_10MHZ = SPI_FREQUENCY_FREQUENCY_M8, SPI_CLK_100KHZ = 100000U,
  SPI_CLK_400KHZ = 400000U, SPI_CLK_1MHZ = 1000000U, SPI_CLK_5MHZ = 5000000U, SPI_CLK_10MHZ = 10000000U,
  SPI_CLK_100KHZ = (100000), SPI_CLK_400KHZ = (400000), SPI_CLK_1MHZ = (1000000), SPI_CLK_5MHZ = (5000000),
  SPI_CLK_10MHZ = (10000000), SPI_CLK_100KHZ = 0, SPI_CLK_400KHZ, SPI_CLK_1MHZ,
  SPI_CLK_5MHZ, SPI_CLK_10MHZ
}
 

Macro Definition Documentation

◆ GPIO_PIN

#define GPIO_PIN (   port,
  pin 
)
Value:
(gpio_t)(((uint32_t)GPIO_A + \
(port << PORTNUM_SHIFT)) | pin)
#define PORTNUM_SHIFT
bit shift for GPIO port
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:69
#define GPIO_A
GPIO Port A instance.
Definition: cc2538_gpio.h:272

For the CC2538, we use OR the gpio ports base register address with the actual pin number.

Definition at line 66 of file cc2538/include/periph_cpu.h.

◆ HAVE_SPI_CLK_T

#define HAVE_SPI_CLK_T

Override SPI clock settings

Definition at line 204 of file cc2538/include/periph_cpu.h.

Enumeration Type Documentation

◆ gpio_mode_t

Enumerator
GPIO_IN 

input, no pull

GPIO_IN_PD 

input, pull-down

GPIO_IN_PU 

input, pull-up

GPIO_OUT 

output

GPIO_OD 

not supported

GPIO_OD_PU 

not supported

GPIO_IN 

in without pull resistor

GPIO_IN_PD 

in with pull-down

GPIO_IN_PU 

in with pull-up

GPIO_OUT 

push-pull output

GPIO_OD 

open-drain output

GPIO_OD_PU 

open-drain output with pull-up

GPIO_IN 

configure as input without pull resistor

GPIO_IN_PD 

configure as input with pull-down resistor

GPIO_IN_PU 

configure as input with pull-up resistor

GPIO_OUT 

configure as output in push-pull mode

GPIO_OD 

configure as output in open-drain mode without pull resistor

GPIO_OD_PU 

configure as output in open-drain mode with pull resistor enabled

Definition at line 177 of file cc2538/include/periph_cpu.h.

◆ spi_clk_t

enum spi_clk_t
Enumerator
SPI_CLK_100KHZ 

16/128 -> 125KHz

SPI_CLK_400KHZ 

16/32 -> 500KHz

SPI_CLK_1MHZ 

16/16 -> 1MHz

SPI_CLK_5MHZ 

16/4 -> 4MHz

SPI_CLK_10MHZ 

16/2 -> 8MHz

SPI_CLK_100KHZ 

drive the SPI bus with 100KHz

SPI_CLK_400KHZ 

drive the SPI bus with 400KHz

SPI_CLK_1MHZ 

drive the SPI bus with 1MHz

SPI_CLK_5MHZ 

drive the SPI bus with 5MHz

SPI_CLK_10MHZ 

drive the SPI bus with 10MHz

SPI_CLK_100KHZ 

drive the SPI bus with 100KHz

SPI_CLK_400KHZ 

drive the SPI bus with 400KHz

SPI_CLK_1MHZ 

drive the SPI bus with 1MHz

SPI_CLK_4MHZ 

drive the SPI bus with 4MHz

SPI_CLK_5MHZ 

drive the SPI bus with 5MHz

SPI_CLK_10MHZ 

drive the SPI bus with 10MHz

SPI_CLK_100KHZ 

drive the SPI bus with 100KHz

SPI_CLK_400KHZ 

drive the SPI bus with 400KHz

SPI_CLK_1MHZ 

drive the SPI bus with 1MHz

SPI_CLK_5MHZ 

drive the SPI bus with 5MHz

SPI_CLK_10MHZ 

actual: 12 MHz

SPI_CLK_100KHZ 

drive the SPI bus with 100KHz

SPI_CLK_400KHZ 

drive the SPI bus with 400KHz

SPI_CLK_1MHZ 

drive the SPI bus with 1MHz

SPI_CLK_5MHZ 

drive the SPI bus with 5MHz

SPI_CLK_10MHZ 

drive the SPI bus with 10MHz

SPI_CLK_100KHZ 

100KHz

SPI_CLK_400KHZ 

400KHz

SPI_CLK_1MHZ 

1MHz

SPI_CLK_5MHZ 

5MHz

SPI_CLK_10MHZ 

10MHz

SPI_CLK_100KHZ 

drive the SPI bus with 100KHz

SPI_CLK_400KHZ 

drive the SPI bus with 400KHz

SPI_CLK_1MHZ 

drive the SPI bus with 1MHz

SPI_CLK_5MHZ 

drive the SPI bus with 5MHz

SPI_CLK_10MHZ 

drive the SPI bus with 10MHz

SPI_CLK_100KHZ 

100KHz

SPI_CLK_400KHZ 

400KHz

SPI_CLK_1MHZ 

1MHz

SPI_CLK_5MHZ 

5MHz

SPI_CLK_10MHZ 

10MHz

SPI_CLK_100KHZ 

drive the SPI bus with 100KHz

SPI_CLK_400KHZ 

drive the SPI bus with 400KHz

SPI_CLK_1MHZ 

drive the SPI bus with 1MHz

SPI_CLK_5MHZ 

drive the SPI bus with 5MHz

SPI_CLK_10MHZ 

drive the SPI bus with 10MHz

Definition at line 205 of file cc2538/include/periph_cpu.h.

◆ spi_mode_t

enum spi_mode_t
Enumerator
SPI_MODE_0 

mode 0

SPI_MODE_1 

mode 1

SPI_MODE_2 

mode 2

SPI_MODE_3 

mode 3

SPI_MODE_0 

CPOL=0, CPHA=0.

SPI_MODE_1 

CPOL=0, CPHA=1.

SPI_MODE_2 

CPOL=1, CPHA=0.

SPI_MODE_3 

CPOL=1, CPHA=1.

SPI_MODE_0 

CPOL=0, CPHA=0.

SPI_MODE_1 

CPOL=0, CPHA=1.

SPI_MODE_2 

CPOL=1, CPHA=0.

SPI_MODE_3 

CPOL=1, CPHA=1.

SPI_MODE_0 

CPOL=0, CPHA=0.

SPI_MODE_1 

CPOL=0, CPHA=1.

SPI_MODE_2 

CPOL=1, CPHA=0.

SPI_MODE_3 

CPOL=1, CPHA=1.

SPI_MODE_0 

CPOL=0, CPHA=0.

SPI_MODE_1 

CPOL=0, CPHA=1.

SPI_MODE_2 

CPOL=1, CPHA=0.

SPI_MODE_3 

CPOL=1, CPHA=1.

SPI_MODE_0 

CPOL=0, CPHA=0.

SPI_MODE_1 

CPOL=0, CPHA=1.

SPI_MODE_2 

CPOL=1, CPHA=0.

SPI_MODE_3 

CPOL=1, CPHA=1.

SPI_MODE_0 

CPOL=0, CPHA=0.

SPI_MODE_1 

CPOL=0, CPHA=1.

SPI_MODE_2 

CPOL=1, CPHA=0.

SPI_MODE_3 

CPOL=1, CPHA=1.

Definition at line 192 of file cc2538/include/periph_cpu.h.

Function Documentation

◆ gpio()

static cc2538_gpio_t* gpio ( gpio_t  pin)
inlinestatic
Parameters
[in]pingpio pin
Returns
pointer to gpio low level device address

Definition at line 76 of file cc2538/include/periph_cpu.h.

◆ gpio_hw_ctrl()

static void gpio_hw_ctrl ( gpio_t  pin)
inlinestatic
Parameters
[in]pingpio pin

Definition at line 134 of file cc2538/include/periph_cpu.h.

◆ gpio_pin_mask()

static uint32_t gpio_pin_mask ( gpio_t  pin)
inlinestatic
Parameters
[in]pingpio pin
Returns
bit mask for gpio pin number, 2^[0 - 7]

Definition at line 112 of file cc2538/include/periph_cpu.h.

◆ gpio_pin_num()

static uint8_t gpio_pin_num ( gpio_t  pin)
inlinestatic
Parameters
[in]pingpio pin
Returns
pin number of gpio pin, [0 - 7]

Definition at line 100 of file cc2538/include/periph_cpu.h.

◆ gpio_port_num()

static uint8_t gpio_port_num ( gpio_t  pin)
inlinestatic
Parameters
[in]pingpio pin
Returns
port number of gpio pin, [0=A - 3=D]

Definition at line 88 of file cc2538/include/periph_cpu.h.

◆ gpio_pp_num()

static uint8_t gpio_pp_num ( gpio_t  pin)
inlinestatic
Parameters
[in]pingpio pin
Returns
number of gpio pin, [0 - 31]

Definition at line 124 of file cc2538/include/periph_cpu.h.

◆ gpio_sw_ctrl()

static void gpio_sw_ctrl ( gpio_t  pin)
inlinestatic
Parameters
[in]pingpio pin

Definition at line 144 of file cc2538/include/periph_cpu.h.