STM32F411: get FastIO for writing into place.
This commit is contained in:
parent
e5494c6951
commit
3a9a442c26
|
|
@ -73,10 +73,14 @@
|
|||
#include "arduino_lpc1114.h"
|
||||
#endif
|
||||
|
||||
#if defined (__ARM_STM32F411__)
|
||||
#include "arduino_stm32f411.h"
|
||||
#endif
|
||||
|
||||
#endif /* __AVR__, __ARMEL__, SIMULATOR */
|
||||
|
||||
#ifndef SIMULATOR
|
||||
#if ! defined DIO0_PIN && ! defined PIO0_1_PIN
|
||||
#if ! defined DIO0_PIN && ! defined PIO0_1_PIN && ! defined PA_1_PIN
|
||||
#error Pins for this chip not defined in arduino.h! If you write an \
|
||||
appropriate pin definition and have this firmware work on your chip, \
|
||||
please tell us via Github or the forum thread.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
|
||||
/** \file
|
||||
\brief MCU pin mappings.
|
||||
|
||||
Here we map the pins required by Teacup to the names known by CMSIS.
|
||||
*/
|
||||
|
||||
/** I/O pins.
|
||||
|
||||
In MBED, I/O pin handling is rather complicated. Lots of enums, lots of
|
||||
functions, spread over various files, slow execution (pin toggling about
|
||||
15 times slower than what we have here).
|
||||
|
||||
FASTIO by setting the BSRR (bit set/reset register),
|
||||
- Bit0-15 to set
|
||||
- Bit16-31 to reset.
|
||||
|
||||
Pins set for Nucleo F411RE, for other STM32F4-boards you need to add them.
|
||||
*/
|
||||
|
||||
#include "mbed-stm32f4xx.h"
|
||||
|
||||
/**
|
||||
We define only pins available on the Nucleo F411RE here.
|
||||
Use alphas for PORT and numerics for PIN, close to the design.
|
||||
*/
|
||||
|
||||
#define PA_0_PIN 0
|
||||
#define PA_0_PORT GPIOA
|
||||
|
||||
#define PA_1_PIN 1
|
||||
#define PA_1_PORT GPIOA
|
||||
|
||||
#define PA_2_PIN 2
|
||||
#define PA_2_PORT GPIOA
|
||||
|
||||
#define PA_3_PIN 3
|
||||
#define PA_3_PORT GPIOA
|
||||
|
||||
#define PA_4_PIN 4
|
||||
#define PA_4_PORT GPIOA
|
||||
|
||||
#define PA_5_PIN 5
|
||||
#define PA_5_PORT GPIOA
|
||||
|
||||
#define PA_6_PIN 6
|
||||
#define PA_6_PORT GPIOA
|
||||
|
||||
#define PA_7_PIN 7
|
||||
#define PA_7_PORT GPIOA
|
||||
|
||||
#define PA_8_PIN 8
|
||||
#define PA_8_PORT GPIOA
|
||||
|
||||
#define PA_9_PIN 9
|
||||
#define PA_9_PORT GPIOA
|
||||
|
||||
#define PA_10_PIN 10
|
||||
#define PA_10_PORT GPIOA
|
||||
|
||||
#define PA_11_PIN 11
|
||||
#define PA_11_PORT GPIOA
|
||||
|
||||
#define PA_12_PIN 12
|
||||
#define PA_12_PORT GPIOA
|
||||
|
||||
#define PA_13_PIN 13
|
||||
#define PA_13_PORT GPIOA
|
||||
|
||||
#define PA_14_PIN 14
|
||||
#define PA_14_PORT GPIOA
|
||||
|
||||
#define PA_15_PIN 15
|
||||
#define PA_15_PORT GPIOA
|
||||
|
||||
#define PB_0_PIN 0
|
||||
#define PB_0_PORT GPIOB
|
||||
|
||||
#define PB_1_PIN 1
|
||||
#define PB_1_PORT GPIOB
|
||||
|
||||
#define PB_2_PIN 2
|
||||
#define PB_2_PORT GPIOB
|
||||
|
||||
#define PB_3_PIN 3
|
||||
#define PB_3_PORT GPIOB
|
||||
|
||||
#define PB_4_PIN 4
|
||||
#define PB_4_PORT GPIOB
|
||||
|
||||
#define PB_5_PIN 5
|
||||
#define PB_5_PORT GPIOB
|
||||
|
||||
#define PB_6_PIN 6
|
||||
#define PB_6_PORT GPIOB
|
||||
|
||||
#define PB_7_PIN 7
|
||||
#define PB_7_PORT GPIOB
|
||||
|
||||
#define PB_8_PIN 8
|
||||
#define PB_8_PORT GPIOB
|
||||
|
||||
#define PB_9_PIN 9
|
||||
#define PB_9_PORT GPIOB
|
||||
|
||||
#define PB_10_PIN 10
|
||||
#define PB_10_PORT GPIOB
|
||||
|
||||
#define PB_12_PIN 12
|
||||
#define PB_12_PORT GPIOB
|
||||
|
||||
#define PB_13_PIN 13
|
||||
#define PB_13_PORT GPIOB
|
||||
|
||||
#define PB_14_PIN 14
|
||||
#define PB_14_PORT GPIOB
|
||||
|
||||
#define PB_15_PIN 15
|
||||
#define PB_15_PORT GPIOB
|
||||
|
||||
#define PC_0_PIN 0
|
||||
#define PC_0_PORT GPIOC
|
||||
|
||||
#define PC_1_PIN 1
|
||||
#define PC_1_PORT GPIOC
|
||||
|
||||
#define PC_2_PIN 2
|
||||
#define PC_2_PORT GPIOC
|
||||
|
||||
#define PC_3_PIN 3
|
||||
#define PC_3_PORT GPIOC
|
||||
|
||||
#define PC_4_PIN 4
|
||||
#define PC_4_PORT GPIOC
|
||||
|
||||
#define PC_5_PIN 5
|
||||
#define PC_5_PORT GPIOC
|
||||
|
||||
#define PC_6_PIN 6
|
||||
#define PC_6_PORT GPIOC
|
||||
|
||||
#define PC_7_PIN 7
|
||||
#define PC_7_PORT GPIOC
|
||||
|
||||
#define PC_8_PIN 8
|
||||
#define PC_8_PORT GPIOC
|
||||
|
||||
#define PC_9_PIN 9
|
||||
#define PC_9_PORT GPIOC
|
||||
|
||||
#define PC_10_PIN 10
|
||||
#define PC_10_PORT GPIOC
|
||||
|
||||
#define PC_11_PIN 11
|
||||
#define PC_11_PORT GPIOC
|
||||
|
||||
#define PC_12_PIN 12
|
||||
#define PC_12_PORT GPIOC
|
||||
|
||||
#define PC_13_PIN 13
|
||||
#define PC_13_PORT GPIOC
|
||||
|
||||
#define PC_14_PIN 14
|
||||
#define PC_14_PORT GPIOC
|
||||
|
||||
#define PC_15_PIN 15
|
||||
#define PC_15_PORT GPIOC
|
||||
|
||||
#define PD_2_PIN 2
|
||||
#define PD_2_PORT GPIOD
|
||||
|
||||
#define PH_0_PIN 0
|
||||
#define PH_0_PORT GPIOH
|
||||
|
||||
#define PH_1_PIN 1
|
||||
#define PH_1_PORT GPIOH
|
||||
30
pinio.h
30
pinio.h
|
|
@ -63,7 +63,7 @@
|
|||
/// Disable pullup resistor.
|
||||
#define _PULL_OFF(IO) _WRITE(IO, 0)
|
||||
|
||||
#elif defined __ARMEL__
|
||||
#elif defined __ARM_LPC1114__
|
||||
|
||||
/**
|
||||
The LPC1114 supports bit-banding by mapping the bit mask to the address.
|
||||
|
|
@ -114,6 +114,32 @@
|
|||
LPC_IOCON->IO ## _CMSIS = (IO ## _OUTPUT | IO_MODEMASK_INACTIVE); \
|
||||
} while (0)
|
||||
|
||||
#elif defined __ARM_STM32F411__
|
||||
/**
|
||||
*/
|
||||
/// Write to a pin.
|
||||
#define _WRITE(IO, v) \
|
||||
do { \
|
||||
if (v) \
|
||||
IO ## _PORT->BSRR = MASK(IO ## _PIN); \
|
||||
else \
|
||||
IO ## _PORT->BSRR = MASK((IO ## _PIN + 16)); \
|
||||
} while (0)
|
||||
|
||||
/** Set pin as output.
|
||||
- reset Pullup
|
||||
- reset direction mode
|
||||
- set output
|
||||
- set speed
|
||||
*/
|
||||
#define _SET_OUTPUT(IO) \
|
||||
do { \
|
||||
IO ## _PORT->PUPDR &= ~(3 << ((IO ## _PIN) << 1)); \
|
||||
IO ## _PORT->MODER &= ~(3 << ((IO ## _PIN) << 1)); \
|
||||
IO ## _PORT->MODER |= (1 << ((IO ## _PIN) << 1)); \
|
||||
IO ## _PORT->OSPEEDR |= (3 << ((IO ## _PIN) << 1)); \
|
||||
} while (0)
|
||||
|
||||
#elif defined SIMULATOR
|
||||
|
||||
#include "simulator.h"
|
||||
|
|
@ -125,7 +151,7 @@
|
|||
#define _PULLUP_ON(IO) _WRITE(IO, 1)
|
||||
#define _PULL_OFF(IO) _WRITE(IO, 0)
|
||||
|
||||
#endif /* __AVR__, __ARMEL__, SIMULATOR */
|
||||
#endif /* __AVR__, __ARM_LPC1114__, __ARM_STM32F411__, SIMULATOR */
|
||||
|
||||
/**
|
||||
Why double up on these macros?
|
||||
|
|
|
|||
Loading…
Reference in New Issue