projet_pololu_et5_ees
Fork of FastIO by
Diff: Devices/FastIO_NUCLEO_F030.h
- Revision:
- 6:da3730030c07
- Child:
- 7:1e784ae11fba
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Devices/FastIO_NUCLEO_F030.h Thu Jul 17 15:08:03 2014 +0000 @@ -0,0 +1,25 @@ +#ifdef TARGET_NUCLEO_F030R8 + +#include "mbed.h" +#include "pinmap.h" + +typedef struct { + uint32_t mask; +} fastio_vars; + +#define PINMASK (1 << STM_PIN(pin)) +#define PORT ((GPIO_TypeDef *)(GPIOA_BASE + 0x0400 * STM_PORT(pin))) + +#define INIT_PIN RCC->AHBENR |= (1 << STM_PORT(pin)); (PORT->MODER &= ~(GPIO_MODER_MODER0_1 << (STM_PIN(pin) * 2))); container.mask = PINMASK +#define DESTROY_PIN + +#define SET_DIR_INPUT (PORT->MODER &= ~(GPIO_MODER_MODER0 << (STM_PIN(pin) * 2))) +#define SET_DIR_OUTPUT (PORT->MODER |= (GPIO_MODER_MODER0_0 << (STM_PIN(pin) * 2))) +#define SET_MODE(pull) pin_mode(pin, pull); + +#define WRITE_PIN_SET (PORT->BSRR = PINMASK) +#define WRITE_PIN_CLR (PORT->BRR = PINMASK) + +#define READ_PIN ((PORT->IDR & container.mask) ? 1 : 0) + +#endif