Contiki 3.x
Files
MKL25Z GPIO and Port

Driver for the MKL25Z GPIO controller. More...

Files

file  gpio.h
 Header file with function declarations for the MKL25Z GPIO module.
 

GPIO Pin Multiplexer Settings.

#define PORT_PCR_MUX_DISABLE   0x000
 
#define PORT_PCR_MUX_GPIO   0x100
 
#define PORT_PCR_MUX_ALT2   0x200
 
#define PORT_PCR_MUX_ALT3   0x300
 
#define PORT_PCR_MUX_ALT4   0x400
 
#define PORT_PCR_MUX_ALT5   0x500
 
#define PORT_PCR_MUX_ALT6   0x600
 
#define PORT_PCR_MUX_ALT7   0x700
 

GPIO Pin Interrupt Settings.

#define PORT_PCR_IRQC_DISABLE   0x00000
 
#define PORT_PCR_IRQC_DMA_RISING   0x10000
 
#define PORT_PCR_IRQC_DMA_FALLING   0x20000
 
#define PORT_PCR_IRQC_DMA_EDGE   0x30000
 
#define PORT_PCR_IRQC_ZERO   0x80000
 
#define PORT_PCR_IRQC_RISING   0x90000
 
#define PORT_PCR_IRQC_FALLING   0xA0000
 
#define PORT_PCR_IRQC_EDGE   0xB0000
 
#define PORT_PCR_IRQC_ONE   0xC0000
 

GPIO Manipulation Functions

void gpio_init ()
 initialise the Port interrupt callback function arrays. More...
 
void port_register_callback (void *f, PORT_Type *port, uint8_t pin)
 Register Port interrupt callback function. More...
 
uint32_t port_pin_to_mask (uint8_t pin)
 Convert a pin number (0 to 31) to a pin mask. More...
 
void port_conf_pin (PORT_Type *Port, uint8_t Pin, uint32_t PCR)
 Configure the specified Pin of the port with PORTx_BASE_PTR with PCR. More...
 
void port_conf_pin_int_disable (PORT_Type *Port, uint8_t Pin)
 Disable interrupt on the specified Pin of the port with PORTx_BASE_PTR. More...
 
void port_conf_pin_int_zero (PORT_Type *Port, uint8_t Pin)
 Configure zero-level interrupt on the specified Pin of the port with PORTx_BASE_PTR. More...
 
void port_conf_pin_int_rise (PORT_Type *Port, uint8_t Pin)
 Configure rising-edge interrupt on the specified Pin of the port with PORTx_BASE_PTR. More...
 
void port_conf_pin_int_fall (PORT_Type *Port, uint8_t Pin)
 Configure falling-edge interrupt on the specified Pin of the port with PORTx_BASE_PTR. More...
 
void port_conf_pin_int_edge (PORT_Type *Port, uint8_t Pin)
 Configure either-edge interrupt on the specified Pin of the port with PORTx_BASE_PTR. More...
 
void port_conf_pin_int_one (PORT_Type *Port, uint8_t Pin)
 Configure one-level interrupt on the specified Pin of the port with PORTx_BASE_PTR. More...
 
uint32_t port_read_isf (PORT_Type *Port)
 Return the Interrupt Status Flags of port with PORTx_BASE_PTR. More...
 
bool port_read_pin_isf (PORT_Type *Port, uint8_t Pin)
 Return the Interrupt Status Flags of Pin in port with PORTx_BASE_PTR. More...
 
void port_clr_isf (PORT_Type *Port, uint32_t Pin_Mask)
 Clear the Interrupt Status Flag of port with PORTx_BASE_PTR. More...
 
bool port_pin_read_isf (PORT_Type *Port, uint8_t Pin)
 Return the Interrupt Status of the Pin in port with PORTx_BASE_PTR. More...
 
void port_pin_clr_isf (PORT_Type *Port, uint8_t Pin)
 Clear the Interrupt Status Flag of Pin in port with PORTx_BASE_PTR. More...
 
void gpio_set_input (GPIO_Type *Port, uint32_t Pin_Mask)
 Set pins with Pin_Mask of port with GPIOn_BASE_PTR to input. More...
 
void gpio_set_output (GPIO_Type *Port, uint32_t Pin_Mask)
 Set pins with Pin_Mask of port with GPIOn_BASE_PTR to output. More...
 
void gpio_set_pin (GPIO_Type *Port, uint32_t Pin_Mask)
 Set pins with Pin_Mask of port with GPIOn_BASE_PTR high. More...
 
void gpio_clr_pin (GPIO_Type *Port, uint32_t Pin_Mask)
 Clear pins with Pin_Mask of port with GPIOn_BASE_PTR low. More...
 
void gpio_tgl_pin (GPIO_Type *Port, uint32_t Pin_Mask)
 Toggle pins with Pin_Mask of port with GPIOn_BASE_PTR low. More...
 
uint32_t gpio_read_pin (GPIO_Type *Port, uint32_t Pin_Mask)
 Read pins with Pin_Mask of port with GPIOn_BASE_PTR. More...
 

Detailed Description

Driver for the MKL25Z GPIO controller.

Function Documentation

void gpio_clr_pin ( GPIO_Type Port,
uint32_t  Pin_Mask 
)

Clear pins with Pin_Mask of port with GPIOn_BASE_PTR low.

Parameters
Port- Port register offset
Pin_MaskPin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80

Definition at line 147 of file gpio.c.

References GPIO_Type::PCOR.

Referenced by clock_init().

void gpio_init ( )

initialise the Port interrupt callback function arrays.

initialise the Port interrupt callback function arrays.

Definition at line 13 of file gpio.c.

References gpio_callbacks, NVIC_CLEAR_PENDING(), NVIC_ENABLE_INT(), and NVIC_Set_Priority().

Referenced by main().

uint32_t gpio_read_pin ( GPIO_Type Port,
uint32_t  Pin_Mask 
)

Read pins with Pin_Mask of port with GPIOn_BASE_PTR.

Parameters
PortGPIO Port register offset
Pin_MaskPin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80
Returns
The value of the pins specified by Pin_Mask

This macro will not return 0 or 1. Instead, it will return the values of the pins specified by PIN_MASK ORd together. Thus, if you pass 0xC3 (0x80 | 0x40 | 0x02 | 0x01) as the Pin_Mask and pins 7 and 0 are high, the macro will return 0x81.

Definition at line 159 of file gpio.c.

References GPIO_Type::PDDR, GPIO_Type::PDIR, and GPIO_Type::PDOR.

void gpio_set_input ( GPIO_Type Port,
uint32_t  Pin_Mask 
)

Set pins with Pin_Mask of port with GPIOn_BASE_PTR to input.

Parameters
Port- Port register offset
Pin_MaskPin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80

Definition at line 129 of file gpio.c.

References GPIO_Type::PDDR.

void gpio_set_output ( GPIO_Type Port,
uint32_t  Pin_Mask 
)

Set pins with Pin_Mask of port with GPIOn_BASE_PTR to output.

Parameters
Port- Port register offset
Pin_MaskPin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80

Definition at line 135 of file gpio.c.

References GPIO_Type::PDDR.

Referenced by clock_init(), and leds_arch_init().

void gpio_set_pin ( GPIO_Type Port,
uint32_t  Pin_Mask 
)

Set pins with Pin_Mask of port with GPIOn_BASE_PTR high.

Parameters
Port- Port register offset
Pin_MaskPin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80

Definition at line 141 of file gpio.c.

References GPIO_Type::PSOR.

void gpio_tgl_pin ( GPIO_Type Port,
uint32_t  Pin_Mask 
)

Toggle pins with Pin_Mask of port with GPIOn_BASE_PTR low.

Parameters
Port- Port register offset
Pin_MaskPin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80

Definition at line 153 of file gpio.c.

References GPIO_Type::PTOR.

void port_clr_isf ( PORT_Type Port,
uint32_t  Pin_Mask 
)

Clear the Interrupt Status Flag of port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin_MaskPin number mask. Pin 0: 0x01, Pin 1: 0x02 ... Pin 7: 0x80

Definition at line 104 of file gpio.c.

References PORT_Type::ISFR.

void port_conf_pin ( PORT_Type Port,
uint8_t  Pin,
uint32_t  PCR 
)

Configure the specified Pin of the port with PORTx_BASE_PTR with PCR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.
PCR- The PCR settings to be applied to the pin

Definition at line 40 of file gpio.c.

References PORT_Type::PCR.

Referenced by clock_init(), and leds_arch_init().

void port_conf_pin_int_disable ( PORT_Type Port,
uint8_t  Pin 
)

Disable interrupt on the specified Pin of the port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.

Definition at line 51 of file gpio.c.

References PORT_Type::PCR.

void port_conf_pin_int_edge ( PORT_Type Port,
uint8_t  Pin 
)

Configure either-edge interrupt on the specified Pin of the port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.

Definition at line 82 of file gpio.c.

References PORT_Type::PCR.

void port_conf_pin_int_fall ( PORT_Type Port,
uint8_t  Pin 
)

Configure falling-edge interrupt on the specified Pin of the port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.

Definition at line 74 of file gpio.c.

References PORT_Type::PCR.

void port_conf_pin_int_one ( PORT_Type Port,
uint8_t  Pin 
)

Configure one-level interrupt on the specified Pin of the port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.

Definition at line 90 of file gpio.c.

References PORT_Type::PCR.

void port_conf_pin_int_rise ( PORT_Type Port,
uint8_t  Pin 
)

Configure rising-edge interrupt on the specified Pin of the port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.

Definition at line 66 of file gpio.c.

References PORT_Type::PCR.

void port_conf_pin_int_zero ( PORT_Type Port,
uint8_t  Pin 
)

Configure zero-level interrupt on the specified Pin of the port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.

Definition at line 58 of file gpio.c.

References PORT_Type::PCR.

void port_pin_clr_isf ( PORT_Type Port,
uint8_t  Pin 
)

Clear the Interrupt Status Flag of Pin in port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be read, from 0 to 31.

Definition at line 120 of file gpio.c.

References PORT_Type::PCR.

bool port_pin_read_isf ( PORT_Type Port,
uint8_t  Pin 
)

Return the Interrupt Status of the Pin in port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be read, from 0 to 31.
Returns
The TRUE if the ISF flag is set, FALSE if not.
uint32_t port_pin_to_mask ( uint8_t  pin)

Convert a pin number (0 to 31) to a pin mask.

Parameters
pinAssociate f with this pin, which is specified by number from 0 to 31
Returns
Pinmask for the selected pin.

Definition at line 46 of file gpio.c.

Referenced by clock_init(), and leds_arch_init().

uint32_t port_read_isf ( PORT_Type Port)

Return the Interrupt Status Flags of port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Returns
The value of ISFR for the given Port.

Definition at line 98 of file gpio.c.

References PORT_Type::ISFR.

bool port_read_pin_isf ( PORT_Type Port,
uint8_t  Pin 
)

Return the Interrupt Status Flags of Pin in port with PORTx_BASE_PTR.

Parameters
Port- Port base pointer
Pin- The number of the pin to be conigured, from 0 to 31.
Returns
1 if ISF set, 0 if not.

Definition at line 110 of file gpio.c.

References PORT_Type::PCR.

void port_register_callback ( void *  f,
PORT_Type port,
uint8_t  pin 
)

Register Port interrupt callback function.

Parameters
fPointer to a function to be called when pin of port generates an interrupt
portAssociate f with this port. port must be specified with its PORTx_BASE_PTR.
pinAssociate f with this pin, which is specified by number from 0 to 31

Definition at line 27 of file gpio.c.

References PORTA, and PORTD.