cleanup all external peripherals

This commit is contained in:
Sebastien Lorquet 2017-05-09 10:01:26 +02:00
parent b2bb795520
commit 14831a18c6
7 changed files with 9 additions and 256 deletions

View File

@ -5,17 +5,4 @@
if ARCH_BOARD_NUCLEO_L432KC if ARCH_BOARD_NUCLEO_L432KC
config NUCLEO_L432KC_AJOY_MINBUTTONS
bool "Minimal Joystick Buttons"
default n if !STM32_USART1
default y if STM32_USART1
depends on AJOYSTICK
---help---
The Itead Joystick shield supports analog X/Y position and up to 5
buttons. Some of these buttons may conflict with other resources
(Button F, for example, conflicts with the default USART1 pin usage).
Selecting this option will return the number of buttons to the
minimal set: SELECT (joystick down), FIRE (BUTTON B), and JUMP
(BUTTON A).
endif # ARCH_BOARD_NUCLEO_L432KC endif # ARCH_BOARD_NUCLEO_L432KC

View File

@ -6,7 +6,7 @@ Nucleoi-l432kc board from ST Micro. See
http://www.st.com/nucleo-l432kc http://www.st.com/nucleo-l432kc
NucleoF476RG: NucleoL432KC:
Microprocessor: 32-bit ARM Cortex M4 at 80MHz STM32L432KCU6 Microprocessor: 32-bit ARM Cortex M4 at 80MHz STM32L432KCU6
Memory: 256 KB Flash and 64 KB SRAM Memory: 256 KB Flash and 64 KB SRAM
@ -315,22 +315,6 @@ mbed
Hardware Hardware
======== ========
GPIO
----
SERIAL_TX=PA_2 USER_BUTTON=PC_13
SERIAL_RX=PA_3 LED1 =PA_5
A0=PA_0 USART2RX D0=PA_3 D8 =PA_9
A1=PA_1 USART2TX D1=PA_2 D9 =PC_7
A2=PA_4 D2=PA_10 WIFI_CS=D10=PB_6 SPI_CS
A3=PB_0 WIFI_INT=D3=PB_3 D11=PA_7 SPI_MOSI
A4=PC_1 SDCS=D4=PB_5 D12=PA_6 SPI_MISO
A5=PC_0 WIFI_EN=D5=PB_4 LED1=D13=PA_5 SPI_SCK
LED2=D6=PB_10 I2C1_SDA=D14=PB_9 Probe
D7=PA_8 I2C1_SCL=D15=PB_8 Probe
From: https://mbed.org/platforms/ST-Nucleo-F401RE/
Buttons Buttons
------- -------
B1 USER: the user button is connected to the I/O PC13 (pin 2) of the STM32 B1 USER: the user button is connected to the I/O PC13 (pin 2) of the STM32

View File

@ -3,6 +3,7 @@
* *
* Copyright (C) 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* Copyright (C) 2017 Sebastien Lorquet. All rights reserved.
* Sebastien Lorquet <sebastien@lorquet.fr> * Sebastien Lorquet <sebastien@lorquet.fr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,8 +35,8 @@
* *
****************************************************************************/ ****************************************************************************/
/* The STM32F411RE has 512Kb of FLASH beginning at address 0x0800:0000 and /* The STM32L432KC has 256Kb of FLASH beginning at address 0x0800:0000 and
* 128Kb of SRAM beginning at address 0x2000:0000. When booting from FLASH, * 64Kb of SRAM beginning at address 0x2000:0000. When booting from FLASH,
* FLASH memory is aliased to address 0x0000:0000 where the code expects to * FLASH memory is aliased to address 0x0000:0000 where the code expects to
* begin execution by jumping to the entry point in the 0x0800:0000 address * begin execution by jumping to the entry point in the 0x0800:0000 address
* range. * range.
@ -43,8 +44,8 @@
MEMORY MEMORY
{ {
flash (rx) : ORIGIN = 0x08000000, LENGTH = 512K flash (rx) : ORIGIN = 0x08000000, LENGTH = 256K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
} }
OUTPUT_ARCH(arm) OUTPUT_ARCH(arm)
@ -85,7 +86,7 @@ SECTIONS
_eronly = ABSOLUTE(.); _eronly = ABSOLUTE(.);
/* The STM32L432KC has 96Kb of SRAM beginning at the following address */ /* The STM32L432KC has 64Kb of SRAM beginning at the following address */
.data : { .data : {
_sdata = ABSOLUTE(.); _sdata = ABSOLUTE(.);

View File

@ -101,192 +101,6 @@
#define GPIO_BTN_USER \ #define GPIO_BTN_USER \
(GPIO_INPUT |GPIO_FLOAT |GPIO_EXTI | GPIO_PORTC | GPIO_PIN13) (GPIO_INPUT |GPIO_FLOAT |GPIO_EXTI | GPIO_PORTC | GPIO_PIN13)
/* The shield uses the following pins:
*
* +5V
* GND
* SERIAL_TX=PA_2 USER_BUTTON=PC_13
* SERIAL_RX=PA_3 LD2=PA_5
*
* Analog Digital
* A0=PA_0 USART2RX D0=PA_3 D8 =PA_9
* A1=PA_1 USART2TX D1=PA_2 D9 =PC_7
* A2=PA_4 D2=PA_10 WIFI_CS=D10=PB_6 SPI_CS
* A3=PB_0 WIFI_INT=D3=PB_3 D11=PA_7 SPI_MOSI
* A4=PC_1 SD_CS=D4=PB_5 D12=PA_6 SPI_MISO
* A5=PC_0 WIFI_EN=D5=PB_4 LD2=D13=PA_5 SPI_SCK
* LED2=D6=PB_10 I2C1_SDA=D14=PB_9 WIFI Probe
* D7=PA_8 I2C1_SCL=D15=PB_8 WIFI Probe
*
* mostly from: https://mbed.org/platforms/ST-Nucleo-F401RE/
*
*/
#ifdef CONFIG_WL_CC3000
# define GPIO_WIFI_INT (GPIO_PORTB | GPIO_PIN3 | GPIO_INPUT | \
GPIO_PULLUP | GPIO_EXTI)
# define GPIO_WIFI_EN (GPIO_PORTB | GPIO_PIN4 | GPIO_OUTPUT_CLEAR | \
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
# define GPIO_WIFI_CS (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_SET | \
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
# define GPIO_D14 (GPIO_PORTB | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | \
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
# define GPIO_D15 (GPIO_PORTB | GPIO_PIN8 | GPIO_OUTPUT_CLEAR | \
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
# define GPIO_D0 (GPIO_PORTA | GPIO_PIN3 | GPIO_INPUT | \
GPIO_PULLUP)
# define GPIO_D1 (GPIO_PORTA | GPIO_PIN2 | GPIO_OUTPUT_CLEAR | \
GPIO_PULLUP)
# define GPIO_D2 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_CLEAR | \
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
# define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | \
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
# define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | \
GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz)
# define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | \
GPIO_PULLUP)
# define GPIO_A3 (GPIO_PORTB | GPIO_PIN0 | GPIO_INPUT | \
GPIO_PULLUP)
#endif
/* SPI1 off */
#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
GPIO_PORTA | GPIO_PIN7)
#define GPIO_SPI1_MISO_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
GPIO_PORTA | GPIO_PIN6)
#define GPIO_SPI1_SCK_OFF (GPIO_INPUT | GPIO_PULLDOWN | \
GPIO_PORTA | GPIO_PIN5)
/* SPI1 chip selects off */
#ifdef CONFIG_WL_CC3000
# define GPIO_SPI_CS_WIFI_OFF \
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
GPIO_PORTB | GPIO_PIN6)
#endif
#ifdef HAVE_MMCSD
# define GPIO_SPI_CS_SD_CARD_OFF \
(GPIO_INPUT | GPIO_PULLDOWN | GPIO_SPEED_2MHz | \
GPIO_PORTB | GPIO_PIN5)
#endif
/* SPI chip selects */
#ifdef CONFIG_WL_CC3000
# define GPIO_SPI_CS_WIFI \
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN6)
#endif
#ifdef HAVE_MMCSD
# define GPIO_SPI_CS_SD_CARD \
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN5)
#endif
/* Devices on the onboard bus.
*
* Note that these are unshifted addresses.
*/
#define NUCLEO_I2C_OBDEV_LED 0x55
#define NUCLEO_I2C_OBDEV_HMC5883 0x1e
/* User GPIOs
*
* GPIO0-1 are for probing WIFI status
*/
#ifdef CONFIG_WL_CC3000
# define GPIO_GPIO0_INPUT \
(GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN8)
# define GPIO_GPIO1_INPUT \
(GPIO_INPUT | GPIO_PULLUP | GPIO_PORTB | GPIO_PIN9)
# define GPIO_GPIO0_OUTPUT \
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN8)
# define GPIO_GPIO1_OUTPUT \
(GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_2MHz | \
GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN9)
#endif
/* Itead Joystick Shield
*
* See http://imall.iteadstudio.com/im120417014.html for more information
* about this joystick.
*
* --------- ----------------- ---------------------------------
* ARDUINO ITEAD NUCLEO-F4x1
* PIN NAME SIGNAL SIGNAL
* --------- ----------------- ---------------------------------
* D3 Button E Output PB3
* D4 Button D Output PB5
* D5 Button C Output PB4
* D6 Button B Output PB10
* D7 Button A Output PA8
* D8 Button F Output PA9
* D9 Button G Output PC7
* A0 Joystick Y Output PA0 ADC1_0
* A1 Joystick X Output PA1 ADC1_1
* --------- ----------------- ---------------------------------
*
* All buttons are pulled on the shield. A sensed low value indicates
* when the button is pressed.
*
* NOTE: Button F cannot be used with the default USART1 configuration
* because PA9 is configured for USART1_RX by default. Use select
* different USART1 pins in the board.h file or select a different
* USART or select CONFIG_NUCLEO_L432KC_AJOY_MINBUTTONS which will
* eliminate all but buttons A, B, and C.
*/
#define ADC_XOUPUT 1 /* X output is on ADC channel 1 */
#define ADC_YOUPUT 0 /* Y output is on ADC channel 0 */
#define GPIO_BUTTON_A \
(GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTA | GPIO_PIN8)
#define GPIO_BUTTON_B \
(GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN10)
#define GPIO_BUTTON_C \
(GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN4)
#define GPIO_BUTTON_D \
(GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN5)
#define GPIO_BUTTON_E \
(GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTB | GPIO_PIN3)
#define GPIO_BUTTON_F \
(GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTA | GPIO_PIN9)
#define GPIO_BUTTON_G \
(GPIO_INPUT | GPIO_PULLUP |GPIO_EXTI | GPIO_PORTC | GPIO_PIN7)
/* Itead Joystick Signal interpretation:
*
* --------- ----------------------- ---------------------------
* BUTTON TYPE NUTTX ALIAS
* --------- ----------------------- ---------------------------
* Button A Large button A JUMP/BUTTON 3
* Button B Large button B FIRE/BUTTON 2
* Button C Joystick select button SELECT/BUTTON 1
* Button D Tiny Button D BUTTON 6
* Button E Tiny Button E BUTTON 7
* Button F Large Button F BUTTON 4
* Button G Large Button G BUTTON 5
* --------- ----------------------- ---------------------------
*/
#define GPIO_BUTTON_1 GPIO_BUTTON_C
#define GPIO_BUTTON_2 GPIO_BUTTON_B
#define GPIO_BUTTON_3 GPIO_BUTTON_A
#define GPIO_BUTTON_4 GPIO_BUTTON_F
#define GPIO_BUTTON_5 GPIO_BUTTON_G
#define GPIO_BUTTON_6 GPIO_BUTTON_D
#define GPIO_BUTTON_7 GPIO_BUTTON_E
#define GPIO_SELECT GPIO_BUTTON_1
#define GPIO_FIRE GPIO_BUTTON_2
#define GPIO_JUMP GPIO_BUTTON_3
/************************************************************************************ /************************************************************************************
* Public Data * Public Data
************************************************************************************/ ************************************************************************************/
@ -299,9 +113,6 @@ extern struct spi_dev_s *g_spi1;
#ifdef CONFIG_STM32L4_SPI2 #ifdef CONFIG_STM32L4_SPI2
extern struct spi_dev_s *g_spi2; extern struct spi_dev_s *g_spi2;
#endif #endif
#ifdef HAVE_MMCSD
extern struct sdio_dev_s *g_sdio;
#endif
/************************************************************************************ /************************************************************************************
* Public Functions * Public Functions
@ -351,18 +162,6 @@ int stm32l4_pwm_setup(void);
int stm32l4_adc_setup(void); int stm32l4_adc_setup(void);
#endif #endif
/****************************************************************************
* Name: board_ajoy_initialize
*
* Description:
* Initialize and register the button joystick driver
*
****************************************************************************/
#ifdef CONFIG_AJOYSTICK
int board_ajoy_initialize(void);
#endif
/**************************************************************************** /****************************************************************************
* Name: board_timer_driver_initialize * Name: board_timer_driver_initialize
* *

View File

@ -71,9 +71,7 @@
************************************************************************************/ ************************************************************************************/
/* Identifying number of each ADC channel. */ /* Identifying number of each ADC channel. */
#ifdef CONFIG_AJOYSTICK
#ifdef CONFIG_ADC_DMA #ifdef CONFIG_ADC_DMA
/* The Itead analog joystick gets inputs on ADC_IN0 and ADC_IN1 */
static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0, 1}; static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0, 1};
@ -84,8 +82,6 @@ static const uint32_t g_adc1_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN0, GPIO_ADC
#else #else
/* Without DMA, only a single channel can be supported */ /* Without DMA, only a single channel can be supported */
/* The Itead analog joystick gets input on ADC_IN0 */
static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0}; static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0};
/* Configurations of pins used byte each ADC channels */ /* Configurations of pins used byte each ADC channels */
@ -93,7 +89,6 @@ static const uint8_t g_adc1_chanlist[ADC1_NCHANNELS] = {0};
static const uint32_t g_adc1_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN0}; static const uint32_t g_adc1_pinlist[ADC1_NCHANNELS] = {GPIO_ADC1_IN0};
#endif /* CONFIG_ADC_DMA */ #endif /* CONFIG_ADC_DMA */
#endif /* CONFIG_AJOYSTICK */
/************************************************************************************ /************************************************************************************
* Private Functions * Private Functions

View File

@ -76,7 +76,7 @@
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_WL_CC3000 #ifdef CONFIG_NET
void up_netinitialize(void) void up_netinitialize(void)
{ {
} }
@ -210,19 +210,6 @@ int board_app_initialize(uintptr_t arg)
} }
#endif #endif
#ifdef CONFIG_AJOYSTICK
/* Initialize and register the joystick driver */
ret = board_ajoy_initialize();
if (ret != OK)
{
syslog(LOG_ERR,
"ERROR: Failed to register the joystick driver: %d\n",
ret);
return ret;
}
#endif
#ifdef CONFIG_TIMER #ifdef CONFIG_TIMER
/* Initialize and register the timer driver */ /* Initialize and register the timer driver */

View File

@ -183,7 +183,7 @@ void board_userled(int led, bool ledon)
{ {
if (led == 1) if (led == 1)
{ {
stm32_gpiowrite(GPIO_LD2, ldeon); stm32_gpiowrite(GPIO_LD2, ledon);
} }
} }