The friendly Operating System for the Internet of Things
kinetis_common/include/periph_cpu.h File Reference

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

Detailed Description

#include <stdint.h>
#include "cpu.h"
+ Include dependency graph for kinetis_common/include/periph_cpu.h:

Go to the source code of this file.

Data Structures

struct  adc_conf_t
 CPU specific ADC configuration. More...
 
struct  dac_conf_t
 CPU specific DAC configuration. More...
 
struct  pit_conf_t
 CPU specific timer PIT module configuration. More...
 
struct  lptmr_conf_t
 CPU specific timer LPTMR module configuration. More...
 
struct  pwm_conf_t
 PWM configuration structure. More...
 
struct  spi_conf_t
 SPI configuration data structure. More...
 

Macros

#define GPIO_UNDEF   (0xffff)
 Definition of a fitting UNDEF value.
 
#define GPIO_PIN(x, y)   (((x + 1) << 12) | (x << 6) | y)
 Define a CPU specific GPIO pin generator macro.
 
#define CPUID_LEN   (16U)
 Length of the CPU_ID in octets.
 
#define GPIO_MODE(pu, pe, od, out)   (pu | (pe << 1) | (od << 5) | (out << 7))
 Generate GPIO mode bitfields. More...
 
#define PWM_CHAN_MAX   (4U)
 Define the maximum number of PWM channels that can be configured.
 
#define SPI_HWCS(x)   (x)
 Define a CPU specific SPI hardware chip select line macro. More...
 
#define SPI_HWCS_NUMOF   (5)
 Kinetis CPUs have a maximum number of 5 hardware chip select lines.
 
#define PM_NUM_MODES   (1U)
 define number of usable power modes
 
#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
 This CPU makes use of the following shared SPI functions.
 
#define PERIPH_SPI_NEEDS_TRANSFER_REG
 
#define PERIPH_SPI_NEEDS_TRANSFER_REGS
 
#define TIMER_PIT_DEV(x)   (TIMER_DEV(0 + (x)))
 Hardware timer type-specific device macros.
 
#define TIMER_LPTMR_DEV(x)   (TIMER_DEV(PIT_NUMOF + (x)))
 

Enumerations

enum  gpio_pcr_t {
  GPIO_AF_ANALOG = PORT_PCR_MUX(0), GPIO_AF_GPIO = PORT_PCR_MUX(1), GPIO_AF_2 = PORT_PCR_MUX(2), GPIO_AF_3 = PORT_PCR_MUX(3),
  GPIO_AF_4 = PORT_PCR_MUX(4), GPIO_AF_5 = PORT_PCR_MUX(5), GPIO_AF_6 = PORT_PCR_MUX(6), GPIO_AF_7 = PORT_PCR_MUX(7),
  GPIO_PCR_OD = (PORT_PCR_ODE_MASK), GPIO_PCR_PD = (PORT_PCR_PE_MASK), GPIO_PCR_PU = (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)
}
 Define a condensed set of PORT PCR values. More...
 
enum  {
  PORT_A = 0, PORT_B = 1, PORT_C = 2, PORT_D = 3,
  PORT_E = 4, PORT_F = 5, PORT_G = 6, GPIO_PORTS_NUMOF
}
 Available ports on the Kinetis family. More...
 
enum  { TIMER_PIT, TIMER_LPTMR }
 Possible timer module types. More...
 

Functions

void gpio_init_port (gpio_t pin, uint32_t pcr)
 CPU internal function for initializing PORTs. More...
 
#define HAVE_GPIO_T
 Overwrite the default gpio_t type definition.
 
typedef uint16_t gpio_t
 

Macro Definition Documentation

#define GPIO_MODE (   pu,
  pe,
  od,
  out 
)    (pu | (pe << 1) | (od << 5) | (out << 7))

We use the following bits to encode the pin mode:

  • bit 0: 0 for pull-down or 1 for pull-up
  • bit 1: pull register enable (as configured in bit 0)
  • bit 5: OD enable
  • bit 7: output or input mode

Definition at line 62 of file kinetis_common/include/periph_cpu.h.

#define SPI_HWCS (   x)    (x)

We simply map the 5 hardware channels to the numbers [0-4], this still allows us to differentiate between GPIP_PINs and SPI_HWSC lines.

Definition at line 75 of file kinetis_common/include/periph_cpu.h.

Enumeration Type Documentation

anonymous enum
Todo:
This is not equal for all members of the Kinetis family, right?
Enumerator
PORT_A 

port A

PORT_B 

port B

PORT_C 

port C

PORT_D 

port D

PORT_E 

port E

PORT_F 

port F

PORT_G 

port G

GPIO_PORTS_NUMOF 

overall number of available ports

Definition at line 146 of file kinetis_common/include/periph_cpu.h.

anonymous enum
Enumerator
TIMER_PIT 

PIT.

TIMER_LPTMR 

LPTMR.

Definition at line 273 of file kinetis_common/include/periph_cpu.h.

enum gpio_pcr_t

To combine values just aggregate them using a logical OR.

Enumerator
GPIO_AF_ANALOG 

use pin as analog input

GPIO_AF_GPIO 

use pin as GPIO

GPIO_AF_2 

use alternate function 2

GPIO_AF_3 

use alternate function 3

GPIO_AF_4 

use alternate function 4

GPIO_AF_5 

use alternate function 5

GPIO_AF_6 

use alternate function 6

GPIO_AF_7 

use alternate function 7

GPIO_PCR_OD 

open-drain mode

GPIO_PCR_PD 

enable pull-down

GPIO_PCR_PU 

enable PU

Definition at line 113 of file kinetis_common/include/periph_cpu.h.

Function Documentation

void gpio_init_port ( gpio_t  pin,
uint32_t  pcr 
)
Parameters
[in]pinpin to initialize
[in]pcrvalue for the PORT's PCR register