mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
cc2538: Clean up port and pin definitions
Homogenize port and pin definitions naming: - PERIPHERAL_FUNCTION_PORT for the port ID, - PERIPHERAL_FUNCTION_PIN for the pin ID, - PERIPHERAL_FUNCTION_PORT_BASE for the port base, - PERIPHERAL_FUNCTION_PIN_MASK for the pin mask. Define only PERIPHERAL_FUNCTION_PORT and PERIPHERAL_FUNCTION_PIN in board.h, and deduce PERIPHERAL_FUNCTION_PORT_BASE and PERIPHERAL_FUNCTION_PIN_MASK in the driver from the former definitions. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
This commit is contained in:
parent
acee82abbb
commit
d2f3795a30
@ -42,6 +42,15 @@
|
|||||||
#include "dev/ssi.h"
|
#include "dev/ssi.h"
|
||||||
#include "dev/gpio.h"
|
#include "dev/gpio.h"
|
||||||
|
|
||||||
|
#define SPI_CLK_PORT_BASE GPIO_PORT_TO_BASE(SPI_CLK_PORT)
|
||||||
|
#define SPI_CLK_PIN_MASK GPIO_PIN_MASK(SPI_CLK_PIN)
|
||||||
|
#define SPI_MOSI_PORT_BASE GPIO_PORT_TO_BASE(SPI_MOSI_PORT)
|
||||||
|
#define SPI_MOSI_PIN_MASK GPIO_PIN_MASK(SPI_MOSI_PIN)
|
||||||
|
#define SPI_MISO_PORT_BASE GPIO_PORT_TO_BASE(SPI_MISO_PORT)
|
||||||
|
#define SPI_MISO_PIN_MASK GPIO_PIN_MASK(SPI_MISO_PIN)
|
||||||
|
#define SPI_SEL_PORT_BASE GPIO_PORT_TO_BASE(SPI_SEL_PORT)
|
||||||
|
#define SPI_SEL_PIN_MASK GPIO_PIN_MASK(SPI_SEL_PIN)
|
||||||
|
|
||||||
/* Default: Motorola mode 3 with 8-bit data words */
|
/* Default: Motorola mode 3 with 8-bit data words */
|
||||||
#ifndef SPI_CONF_PHASE
|
#ifndef SPI_CONF_PHASE
|
||||||
#define SPI_CONF_PHASE SSI_CR0_SPH
|
#define SPI_CONF_PHASE SSI_CR0_SPH
|
||||||
@ -61,10 +70,10 @@
|
|||||||
* \brief Initialize the SPI bus.
|
* \brief Initialize the SPI bus.
|
||||||
*
|
*
|
||||||
* This SPI init() function uses the following #defines to set the pins:
|
* This SPI init() function uses the following #defines to set the pins:
|
||||||
* CC2538_SPI_CLK_PORT_NUM CC2538_SPI_CLK_PIN_NUM
|
* SPI_CLK_PORT SPI_CLK_PIN
|
||||||
* CC2538_SPI_MOSI_PORT_NUM CC2538_SPI_MOSI_PIN_NUM
|
* SPI_MOSI_PORT SPI_MOSI_PIN
|
||||||
* CC2538_SPI_MISO_PORT_NUM CC2538_SPI_MISO_PIN_NUM
|
* SPI_MISO_PORT SPI_MISO_PIN
|
||||||
* CC2538_SPI_SEL_PORT_NUM CC2538_SPI_SEL_PIN_NUM
|
* SPI_SEL_PORT SPI_SEL_PIN
|
||||||
*
|
*
|
||||||
* This sets the mode to Motorola SPI with the following format options:
|
* This sets the mode to Motorola SPI with the following format options:
|
||||||
* SPI_CONF_PHASE: 0 or SSI_CR0_SPH
|
* SPI_CONF_PHASE: 0 or SSI_CR0_SPH
|
||||||
@ -83,22 +92,22 @@ spi_init(void)
|
|||||||
REG(SSI0_BASE + SSI_CC) = 1;
|
REG(SSI0_BASE + SSI_CC) = 1;
|
||||||
|
|
||||||
/* Set the mux correctly to connect the SSI pins to the correct GPIO pins */
|
/* Set the mux correctly to connect the SSI pins to the correct GPIO pins */
|
||||||
ioc_set_sel(CC2538_SPI_CLK_PORT_NUM, CC2538_SPI_CLK_PIN_NUM, IOC_PXX_SEL_SSI0_CLKOUT);
|
ioc_set_sel(SPI_CLK_PORT, SPI_CLK_PIN, IOC_PXX_SEL_SSI0_CLKOUT);
|
||||||
ioc_set_sel(CC2538_SPI_MOSI_PORT_NUM, CC2538_SPI_MOSI_PIN_NUM, IOC_PXX_SEL_SSI0_TXD);
|
ioc_set_sel(SPI_MOSI_PORT, SPI_MOSI_PIN, IOC_PXX_SEL_SSI0_TXD);
|
||||||
REG(IOC_SSIRXD_SSI0) = (CC2538_SPI_MISO_PORT_NUM * 8) + CC2538_SPI_MISO_PIN_NUM;
|
REG(IOC_SSIRXD_SSI0) = (SPI_MISO_PORT * 8) + SPI_MISO_PIN;
|
||||||
ioc_set_sel(CC2538_SPI_SEL_PORT_NUM, CC2538_SPI_SEL_PIN_NUM, IOC_PXX_SEL_SSI0_FSSOUT);
|
ioc_set_sel(SPI_SEL_PORT, SPI_SEL_PIN, IOC_PXX_SEL_SSI0_FSSOUT);
|
||||||
|
|
||||||
/* Put all the SSI gpios into peripheral mode */
|
/* Put all the SSI gpios into peripheral mode */
|
||||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_CLK_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_CLK_PIN_NUM));
|
GPIO_PERIPHERAL_CONTROL(SPI_CLK_PORT_BASE, SPI_CLK_PIN_MASK);
|
||||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_MOSI_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_MOSI_PIN_NUM));
|
GPIO_PERIPHERAL_CONTROL(SPI_MOSI_PORT_BASE, SPI_MOSI_PIN_MASK);
|
||||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_MISO_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_MISO_PIN_NUM));
|
GPIO_PERIPHERAL_CONTROL(SPI_MISO_PORT_BASE, SPI_MISO_PIN_MASK);
|
||||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(CC2538_SPI_SEL_PORT_NUM), GPIO_PIN_MASK(CC2538_SPI_SEL_PIN_NUM));
|
GPIO_PERIPHERAL_CONTROL(SPI_SEL_PORT_BASE, SPI_SEL_PIN_MASK);
|
||||||
|
|
||||||
/* Disable any pull ups or the like */
|
/* Disable any pull ups or the like */
|
||||||
ioc_set_over(CC2538_SPI_CLK_PORT_NUM, CC2538_SPI_CLK_PIN_NUM, IOC_OVERRIDE_DIS);
|
ioc_set_over(SPI_CLK_PORT, SPI_CLK_PIN, IOC_OVERRIDE_DIS);
|
||||||
ioc_set_over(CC2538_SPI_MOSI_PORT_NUM, CC2538_SPI_MOSI_PIN_NUM, IOC_OVERRIDE_DIS);
|
ioc_set_over(SPI_MOSI_PORT, SPI_MOSI_PIN, IOC_OVERRIDE_DIS);
|
||||||
ioc_set_over(CC2538_SPI_MISO_PORT_NUM, CC2538_SPI_MISO_PIN_NUM, IOC_OVERRIDE_DIS);
|
ioc_set_over(SPI_MISO_PORT, SPI_MISO_PIN, IOC_OVERRIDE_DIS);
|
||||||
ioc_set_over(CC2538_SPI_SEL_PORT_NUM, CC2538_SPI_SEL_PIN_NUM, IOC_OVERRIDE_DIS);
|
ioc_set_over(SPI_SEL_PORT, SPI_SEL_PIN, IOC_OVERRIDE_DIS);
|
||||||
|
|
||||||
/* Configure the clock */
|
/* Configure the clock */
|
||||||
REG(SSI0_BASE + SSI_CPSR) = 2;
|
REG(SSI0_BASE + SSI_CPSR) = 2;
|
||||||
|
@ -50,6 +50,18 @@
|
|||||||
|
|
||||||
static int (* input_handler)(unsigned char c);
|
static int (* input_handler)(unsigned char c);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define UART_RX_PORT_BASE GPIO_PORT_TO_BASE(UART_RX_PORT)
|
||||||
|
#define UART_RX_PIN_MASK GPIO_PIN_MASK(UART_RX_PIN)
|
||||||
|
|
||||||
|
#define UART_TX_PORT_BASE GPIO_PORT_TO_BASE(UART_TX_PORT)
|
||||||
|
#define UART_TX_PIN_MASK GPIO_PIN_MASK(UART_TX_PIN)
|
||||||
|
|
||||||
|
#define UART_CTS_PORT_BASE GPIO_PORT_TO_BASE(UART_CTS_PORT)
|
||||||
|
#define UART_CTS_PIN_MASK GPIO_PIN_MASK(UART_CTS_PIN)
|
||||||
|
|
||||||
|
#define UART_RTS_PORT_BASE GPIO_PORT_TO_BASE(UART_RTS_PORT)
|
||||||
|
#define UART_RTS_PIN_MASK GPIO_PIN_MASK(UART_RTS_PIN)
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/*
|
/*
|
||||||
* Once we know what UART we're on, configure correct values to be written to
|
* Once we know what UART we're on, configure correct values to be written to
|
||||||
* the correct registers
|
* the correct registers
|
||||||
@ -138,8 +150,8 @@ uart_init(void)
|
|||||||
ioc_set_over(UART_TX_PORT, UART_TX_PIN, IOC_OVERRIDE_OE);
|
ioc_set_over(UART_TX_PORT, UART_TX_PIN, IOC_OVERRIDE_OE);
|
||||||
|
|
||||||
/* Set RX and TX pins to peripheral mode */
|
/* Set RX and TX pins to peripheral mode */
|
||||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(UART_TX_PORT), GPIO_PIN_MASK(UART_TX_PIN));
|
GPIO_PERIPHERAL_CONTROL(UART_TX_PORT_BASE, UART_TX_PIN_MASK);
|
||||||
GPIO_PERIPHERAL_CONTROL(GPIO_PORT_TO_BASE(UART_RX_PORT), GPIO_PIN_MASK(UART_RX_PIN));
|
GPIO_PERIPHERAL_CONTROL(UART_RX_PORT_BASE, UART_RX_PIN_MASK);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UART Interrupt Masks:
|
* UART Interrupt Masks:
|
||||||
|
@ -54,6 +54,9 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#define USB_PULLUP_PORT_BASE GPIO_PORT_TO_BASE(USB_PULLUP_PORT)
|
||||||
|
#define USB_PULLUP_PIN_MASK GPIO_PIN_MASK(USB_PULLUP_PIN)
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/* EP max FIFO sizes without double buffering */
|
/* EP max FIFO sizes without double buffering */
|
||||||
#if CTRL_EP_SIZE > 32
|
#if CTRL_EP_SIZE > 32
|
||||||
#error Control endpoint size too big
|
#error Control endpoint size too big
|
||||||
@ -330,8 +333,8 @@ usb_arch_setup(void)
|
|||||||
while(!(REG(USB_CTRL) & USB_CTRL_PLL_LOCKED));
|
while(!(REG(USB_CTRL) & USB_CTRL_PLL_LOCKED));
|
||||||
|
|
||||||
/* Enable pull-up on usb port */
|
/* Enable pull-up on usb port */
|
||||||
GPIO_SET_OUTPUT(USB_PULLUP_PORT, USB_PULLUP_PIN_MASK);
|
GPIO_SET_OUTPUT(USB_PULLUP_PORT_BASE, USB_PULLUP_PIN_MASK);
|
||||||
GPIO_SET_PIN(USB_PULLUP_PORT, USB_PULLUP_PIN_MASK);
|
GPIO_SET_PIN(USB_PULLUP_PORT_BASE, USB_PULLUP_PIN_MASK);
|
||||||
|
|
||||||
for(i = 0; i < USB_MAX_ENDPOINTS; i++) {
|
for(i = 0; i < USB_MAX_ENDPOINTS; i++) {
|
||||||
usb_endpoints[i].flags = 0;
|
usb_endpoints[i].flags = 0;
|
||||||
|
@ -97,9 +97,8 @@
|
|||||||
*
|
*
|
||||||
* The USB pullup is driven by PC0 and is shared with LED1
|
* The USB pullup is driven by PC0 and is shared with LED1
|
||||||
*/
|
*/
|
||||||
#define USB_PULLUP_PORT GPIO_C_BASE
|
#define USB_PULLUP_PORT GPIO_C_NUM
|
||||||
#define USB_PULLUP_PIN 0
|
#define USB_PULLUP_PIN 0
|
||||||
#define USB_PULLUP_PIN_MASK GPIO_PIN_MASK(USB_PULLUP_PIN)
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** \name UART configuration
|
/** \name UART configuration
|
||||||
@ -140,38 +139,28 @@
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
/** BUTTON_SELECT -> PA3 */
|
/** BUTTON_SELECT -> PA3 */
|
||||||
#define BUTTON_SELECT_PORT_NO GPIO_A_NUM
|
#define BUTTON_SELECT_PORT GPIO_A_NUM
|
||||||
#define BUTTON_SELECT_PIN 3
|
#define BUTTON_SELECT_PIN 3
|
||||||
#define BUTTON_SELECT_PORT GPIO_A_BASE
|
|
||||||
#define BUTTON_SELECT_PIN_MASK GPIO_PIN_MASK(BUTTON_SELECT_PIN)
|
|
||||||
#define BUTTON_SELECT_VECTOR NVIC_INT_GPIO_PORT_A
|
#define BUTTON_SELECT_VECTOR NVIC_INT_GPIO_PORT_A
|
||||||
|
|
||||||
/** BUTTON_LEFT -> PC4 */
|
/** BUTTON_LEFT -> PC4 */
|
||||||
#define BUTTON_LEFT_PORT_NO GPIO_C_NUM
|
#define BUTTON_LEFT_PORT GPIO_C_NUM
|
||||||
#define BUTTON_LEFT_PIN 4
|
#define BUTTON_LEFT_PIN 4
|
||||||
#define BUTTON_LEFT_PORT GPIO_C_BASE
|
|
||||||
#define BUTTON_LEFT_PIN_MASK GPIO_PIN_MASK(BUTTON_LEFT_PIN)
|
|
||||||
#define BUTTON_LEFT_VECTOR NVIC_INT_GPIO_PORT_C
|
#define BUTTON_LEFT_VECTOR NVIC_INT_GPIO_PORT_C
|
||||||
|
|
||||||
/** BUTTON_RIGHT -> PC5 */
|
/** BUTTON_RIGHT -> PC5 */
|
||||||
#define BUTTON_RIGHT_PORT_NO GPIO_C_NUM
|
#define BUTTON_RIGHT_PORT GPIO_C_NUM
|
||||||
#define BUTTON_RIGHT_PIN 5
|
#define BUTTON_RIGHT_PIN 5
|
||||||
#define BUTTON_RIGHT_PORT GPIO_C_BASE
|
|
||||||
#define BUTTON_RIGHT_PIN_MASK GPIO_PIN_MASK(BUTTON_RIGHT_PIN)
|
|
||||||
#define BUTTON_RIGHT_VECTOR NVIC_INT_GPIO_PORT_C
|
#define BUTTON_RIGHT_VECTOR NVIC_INT_GPIO_PORT_C
|
||||||
|
|
||||||
/** BUTTON_UP -> PC6 */
|
/** BUTTON_UP -> PC6 */
|
||||||
#define BUTTON_UP_PORT_NO GPIO_C_NUM
|
#define BUTTON_UP_PORT GPIO_C_NUM
|
||||||
#define BUTTON_UP_PIN 6
|
#define BUTTON_UP_PIN 6
|
||||||
#define BUTTON_UP_PORT GPIO_C_BASE
|
|
||||||
#define BUTTON_UP_PIN_MASK GPIO_PIN_MASK(BUTTON_UP_PIN)
|
|
||||||
#define BUTTON_UP_VECTOR NVIC_INT_GPIO_PORT_C
|
#define BUTTON_UP_VECTOR NVIC_INT_GPIO_PORT_C
|
||||||
|
|
||||||
/** BUTTON_DOWN -> PC7 */
|
/** BUTTON_DOWN -> PC7 */
|
||||||
#define BUTTON_DOWN_PORT_NO GPIO_C_NUM
|
#define BUTTON_DOWN_PORT GPIO_C_NUM
|
||||||
#define BUTTON_DOWN_PIN 7
|
#define BUTTON_DOWN_PIN 7
|
||||||
#define BUTTON_DOWN_PORT GPIO_C_BASE
|
|
||||||
#define BUTTON_DOWN_PIN_MASK GPIO_PIN_MASK(BUTTON_DOWN_PIN)
|
|
||||||
#define BUTTON_DOWN_VECTOR NVIC_INT_GPIO_PORT_C
|
#define BUTTON_DOWN_VECTOR NVIC_INT_GPIO_PORT_C
|
||||||
|
|
||||||
/* Notify various examples that we have Buttons */
|
/* Notify various examples that we have Buttons */
|
||||||
@ -184,14 +173,14 @@
|
|||||||
* These values configure which CC2538 pins to use for the SPI lines.
|
* These values configure which CC2538 pins to use for the SPI lines.
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define CC2538_SPI_CLK_PORT_NUM GPIO_A_NUM
|
#define SPI_CLK_PORT GPIO_A_NUM
|
||||||
#define CC2538_SPI_CLK_PIN_NUM 2
|
#define SPI_CLK_PIN 2
|
||||||
#define CC2538_SPI_MOSI_PORT_NUM GPIO_A_NUM
|
#define SPI_MOSI_PORT GPIO_A_NUM
|
||||||
#define CC2538_SPI_MOSI_PIN_NUM 4
|
#define SPI_MOSI_PIN 4
|
||||||
#define CC2538_SPI_MISO_PORT_NUM GPIO_A_NUM
|
#define SPI_MISO_PORT GPIO_A_NUM
|
||||||
#define CC2538_SPI_MISO_PIN_NUM 5
|
#define SPI_MISO_PIN 5
|
||||||
#define CC2538_SPI_SEL_PORT_NUM GPIO_B_NUM
|
#define SPI_SEL_PORT GPIO_B_NUM
|
||||||
#define CC2538_SPI_SEL_PIN_NUM 5
|
#define SPI_SEL_PIN 5
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +45,21 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define BUTTON_SELECT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_SELECT_PORT)
|
||||||
|
#define BUTTON_SELECT_PIN_MASK GPIO_PIN_MASK(BUTTON_SELECT_PIN)
|
||||||
|
|
||||||
|
#define BUTTON_LEFT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_LEFT_PORT)
|
||||||
|
#define BUTTON_LEFT_PIN_MASK GPIO_PIN_MASK(BUTTON_LEFT_PIN)
|
||||||
|
|
||||||
|
#define BUTTON_RIGHT_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_RIGHT_PORT)
|
||||||
|
#define BUTTON_RIGHT_PIN_MASK GPIO_PIN_MASK(BUTTON_RIGHT_PIN)
|
||||||
|
|
||||||
|
#define BUTTON_UP_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_UP_PORT)
|
||||||
|
#define BUTTON_UP_PIN_MASK GPIO_PIN_MASK(BUTTON_UP_PIN)
|
||||||
|
|
||||||
|
#define BUTTON_DOWN_PORT_BASE GPIO_PORT_TO_BASE(BUTTON_DOWN_PORT)
|
||||||
|
#define BUTTON_DOWN_PIN_MASK GPIO_PIN_MASK(BUTTON_DOWN_PIN)
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static struct timer debouncetimer;
|
static struct timer debouncetimer;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
@ -124,14 +139,13 @@ btn_callback(uint8_t port, uint8_t pin)
|
|||||||
static int
|
static int
|
||||||
config_select(int type, int value)
|
config_select(int type, int value)
|
||||||
{
|
{
|
||||||
config(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN_MASK);
|
config(BUTTON_SELECT_PORT_BASE, BUTTON_SELECT_PIN_MASK);
|
||||||
|
|
||||||
ioc_set_over(BUTTON_SELECT_PORT_NO, BUTTON_SELECT_PIN, IOC_OVERRIDE_PUE);
|
ioc_set_over(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN, IOC_OVERRIDE_PUE);
|
||||||
|
|
||||||
nvic_interrupt_enable(BUTTON_SELECT_VECTOR);
|
nvic_interrupt_enable(BUTTON_SELECT_VECTOR);
|
||||||
|
|
||||||
gpio_register_callback(btn_callback, BUTTON_SELECT_PORT_NO,
|
gpio_register_callback(btn_callback, BUTTON_SELECT_PORT, BUTTON_SELECT_PIN);
|
||||||
BUTTON_SELECT_PIN);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -149,14 +163,13 @@ config_select(int type, int value)
|
|||||||
static int
|
static int
|
||||||
config_left(int type, int value)
|
config_left(int type, int value)
|
||||||
{
|
{
|
||||||
config(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN_MASK);
|
config(BUTTON_LEFT_PORT_BASE, BUTTON_LEFT_PIN_MASK);
|
||||||
|
|
||||||
ioc_set_over(BUTTON_LEFT_PORT_NO, BUTTON_LEFT_PIN, IOC_OVERRIDE_PUE);
|
ioc_set_over(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN, IOC_OVERRIDE_PUE);
|
||||||
|
|
||||||
nvic_interrupt_enable(BUTTON_LEFT_VECTOR);
|
nvic_interrupt_enable(BUTTON_LEFT_VECTOR);
|
||||||
|
|
||||||
gpio_register_callback(btn_callback, BUTTON_LEFT_PORT_NO,
|
gpio_register_callback(btn_callback, BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
|
||||||
BUTTON_LEFT_PIN);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -174,14 +187,13 @@ config_left(int type, int value)
|
|||||||
static int
|
static int
|
||||||
config_right(int type, int value)
|
config_right(int type, int value)
|
||||||
{
|
{
|
||||||
config(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN_MASK);
|
config(BUTTON_RIGHT_PORT_BASE, BUTTON_RIGHT_PIN_MASK);
|
||||||
|
|
||||||
ioc_set_over(BUTTON_RIGHT_PORT_NO, BUTTON_RIGHT_PIN, IOC_OVERRIDE_PUE);
|
ioc_set_over(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN, IOC_OVERRIDE_PUE);
|
||||||
|
|
||||||
nvic_interrupt_enable(BUTTON_RIGHT_VECTOR);
|
nvic_interrupt_enable(BUTTON_RIGHT_VECTOR);
|
||||||
|
|
||||||
gpio_register_callback(btn_callback, BUTTON_RIGHT_PORT_NO,
|
gpio_register_callback(btn_callback, BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN);
|
||||||
BUTTON_RIGHT_PIN);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -199,14 +211,13 @@ config_right(int type, int value)
|
|||||||
static int
|
static int
|
||||||
config_up(int type, int value)
|
config_up(int type, int value)
|
||||||
{
|
{
|
||||||
config(BUTTON_UP_PORT, BUTTON_UP_PIN_MASK);
|
config(BUTTON_UP_PORT_BASE, BUTTON_UP_PIN_MASK);
|
||||||
|
|
||||||
ioc_set_over(BUTTON_UP_PORT_NO, BUTTON_UP_PIN, IOC_OVERRIDE_PUE);
|
ioc_set_over(BUTTON_UP_PORT, BUTTON_UP_PIN, IOC_OVERRIDE_PUE);
|
||||||
|
|
||||||
nvic_interrupt_enable(BUTTON_UP_VECTOR);
|
nvic_interrupt_enable(BUTTON_UP_VECTOR);
|
||||||
|
|
||||||
gpio_register_callback(btn_callback, BUTTON_UP_PORT_NO,
|
gpio_register_callback(btn_callback, BUTTON_UP_PORT, BUTTON_UP_PIN);
|
||||||
BUTTON_UP_PIN);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -224,14 +235,13 @@ config_up(int type, int value)
|
|||||||
static int
|
static int
|
||||||
config_down(int type, int value)
|
config_down(int type, int value)
|
||||||
{
|
{
|
||||||
config(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN_MASK);
|
config(BUTTON_DOWN_PORT_BASE, BUTTON_DOWN_PIN_MASK);
|
||||||
|
|
||||||
ioc_set_over(BUTTON_DOWN_PORT_NO, BUTTON_DOWN_PIN, IOC_OVERRIDE_PUE);
|
ioc_set_over(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN, IOC_OVERRIDE_PUE);
|
||||||
|
|
||||||
nvic_interrupt_enable(BUTTON_DOWN_VECTOR);
|
nvic_interrupt_enable(BUTTON_DOWN_VECTOR);
|
||||||
|
|
||||||
gpio_register_callback(btn_callback, BUTTON_DOWN_PORT_NO,
|
gpio_register_callback(btn_callback, BUTTON_DOWN_PORT, BUTTON_DOWN_PIN);
|
||||||
BUTTON_DOWN_PIN);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user