pin state
This commit is contained in:
parent
b32090075e
commit
55d723bfd4
@ -1 +1 @@
|
|||||||
Subproject commit 654ad8baad7c7d7a66ab52ed2df59b806d3c56a0
|
Subproject commit 7bcb3a7afa7bb6ca19d1c33939bd28d2a9db5b98
|
@ -3,14 +3,28 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
uint8_t gpio_status[4][64];
|
||||||
|
|
||||||
|
static uint8_t get_1st_pin_from_bitmask(uint16_t bitmask){
|
||||||
|
for(int i = 0; i < 16; i++){
|
||||||
|
if(bitmask & (1 << i)) return i;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin){
|
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin){
|
||||||
|
uint8_t pin = get_1st_pin_from_bitmask(GPIO_Pin);
|
||||||
|
gpio_status[GPIOx->index][pin] = !gpio_status[GPIOx->index][pin];
|
||||||
printf("toggling pin\n");
|
printf("toggling pin\n");
|
||||||
}
|
}
|
||||||
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin){
|
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin){
|
||||||
printf("reading pin, returning 0\n");
|
printf("reading pin\n");
|
||||||
return GPIO_PIN_RESET;
|
uint8_t pin = get_1st_pin_from_bitmask(GPIO_Pin);
|
||||||
|
return gpio_status[GPIOx->index][pin];
|
||||||
}
|
}
|
||||||
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState){
|
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState){
|
||||||
|
uint8_t pin = get_1st_pin_from_bitmask(GPIO_Pin);
|
||||||
|
gpio_status[GPIOx->index][pin] = PinState;
|
||||||
printf("writing pin\n");
|
printf("writing pin\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user