13 uint8_t pa_odr
, pb_idr
, dummy
;
21 void setBit(uint8_t* port
, uint8_t bit
){
22 (*(port
)) |= (1 << bit
);
25 void clearBit(uint8_t* port
, uint8_t bit
){
26 (*(port
)) &= ~(1 << bit
);
29 void toggleBit(uint8_t* port
, uint8_t bit
){
30 (*(port
)) ^= (1 << bit
);
33 uint8_t extractBit(uint8_t port
, uint8_t bit
){
34 return ((port
& (1 << bit
)) >> bit
);
37 void writeBit(uint8_t* port
, uint8_t bit
, uint8_t value
){
48 setBit(&PA_DDR
, 1); // configure PA1 as output
49 setBit(&PA_CR1
, 1); // push-pull mode
50 setBit(&PA_CR2
, 1); // high speed
54 writeBit(&PA_ODR
, 1, extractBit(PB_IDR
, 2));
58 void writeBit2(uint8_t* port
, uint8_t bit
, uint8_t value
){
69 setBit(&PA_DDR
, 1); // configure PA1 as output
70 setBit(&PA_CR1
, 1); // push-pull mode
71 setBit(&PA_CR2
, 1); // high speed
75 writeBit2(&PA_ODR
, 1, extractBit(PB_IDR
, 2));
85 ASSERT (PA_ODR
== 1 << 1);
91 ASSERT (PA_ODR
== 0 << 1);
96 ASSERT (PA_ODR
== 1 << 1);
101 ASSERT (PA_ODR
== 0 << 1);