Back to STM_Pin<Pin_no::pin_3, GPIO_Port::Port_B_base_address> led; but we need do update the asserts for compilation

interrupts
key 4 years ago
parent cc2c1d766f
commit 681bd375cc

@ -20,6 +20,27 @@
#define PUPDR_PULL_DOWN 0x2UL
// https://accu.org/journals/overload/13/68/goodliffe_281/
#define LQFP32 // TODO : If that makes sens it will be implmendet on the Cmake.
// How can we check the assert for each port ?
#ifdef LQFP32
#define PORT_A_PIN_COUNT 15
#define PORT_B_PIN_COUNT 8
#define PORT_C_PIN_COUNT 0
#define PORT_F_PIN_COUNT 2
// 0b1111 1111 Means all the piuns are present it's to de bale to make an & comprison
#define PORT_A_PIN_MISSING_MSK 0xFF
#define PORT_B_PIN_MISSING_MSK 0xFB
#define PORT_C_PIN_MISSING_MSK 0x00
#define PORT_F_PIN_MISSING_MSK 0xFC
#endif
enum GPIO_Port {
Port_A_base_address = GPIOA_BASE, // 0x4800'0000
Port_B_base_address = GPIOB_BASE, // 0x4800'0400
@ -28,23 +49,31 @@ enum GPIO_Port {
};
enum Pin_no{
pin_0,
pin_1,
pin_2,
pin_3,
pin_4,
pin_5,
pin_6,
pin_7
pin_0,
pin_1,
pin_2,
pin_3,
pin_4,
pin_5,
pin_6,
pin_8,
pin_9,
pin_10,
pin_11,
pin_12,
pin_13,
pin_14,
pin_15
};
template <uint8_t pin_no, GPIO_Port port_base_address>
template <Pin_no pin_no, GPIO_Port port_base_address>
class STM_Pin : Pin
{
public:
STM_Pin() {
static_assert(pin_no < 7, "GPIO has only 8 ports!");
static_assert(pin_no < PORT_A_PIN_COUNT, "GPIO has only 14 ports!");
}
void setMode(mode mode) override

@ -4,8 +4,8 @@ int startBSL()
stmStart();
Delay delay;
STM_Pin<LED_PIN, LED_PORT> led;
STM_Pin<A0_PIN, A0_PORT> pin_a0;
STM_Pin<Pin_no::pin_3, GPIO_Port::Port_B_base_address> led;
STM_Pin<Pin_no::pin_0, GPIO_Port::Port_A_base_address> pin_a0;
led.init();
led.setMode(Pin::mode::output);

@ -7,75 +7,4 @@
#include "stm32f0xx_csl.h"
int startBSL();
#define PORT_A Port_A_base_address
#define PORT_B Port_B_base_address
#define PORT_C Port_C_base_address
#define PORT_F Port_F_base_address
#define D0_PORT PORT_A
#define D0_PIN 10
#define D1_PORT PORT_A
#define D1_PIN 9
#define D2_PORT PORT_A
#define D2_PIN 12
#define D3_PORT PORT_B
#define D3_PIN 0
#define D4_PORT PORT_B
#define D4_PIN 7
#define D5_PORT PORT_B
#define D5_PIN 6
#define D6_PORT PORT_B
#define D6_PIN 1
#define D7_PORT PORT_F
#define D7_PIN 0
#define D8_PORT PORT_F
#define D8_PIN 1
#define D10_PORT PORT_A
#define D10_PIN 11
#define D11_PORT PORT_B
#define D11_PIN 5
#define D12_PORT PORT_B
#define D12_PIN 4
#define D13_PORT PORT_B
#define D13_PIN 3
#define A0_PORT PORT_A
#define A0_PIN 0
#define A1_PORT PORT_A
#define A1_PIN 1
#define A2_PORT PORT_A
#define A2_PIN 3
#define A3_PORT PORT_A
#define A3_PIN 4
#define A4_PORT PORT_A
#define A4_PIN 5
#define A5_PORT PORT_A
#define A5_PIN 6
#define A6_PORT PORT_A
#define A6_PIN 7
#define A7_PORT PORT_A
#define A7_PIN 2
#define LED_PORT D13_PORT
#define LED_PIN D13_PIN
#endif /* BSL_NUCLEO_F042K6_H */

Loading…
Cancel
Save