Replaced setPin and resetPin by gpio_write_bit
This commit is contained in:
parent
c84d51e16e
commit
2c575f56b0
Binary file not shown.
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
/*
|
||||||
void setPin(u32 bank, u8 pin) {
|
void setPin(u32 bank, u8 pin) {
|
||||||
u32 pinMask = 0x1 << (pin);
|
u32 pinMask = 0x1 << (pin);
|
||||||
SET_REG(GPIO_BSRR(bank), pinMask);
|
SET_REG(GPIO_BSRR(bank), pinMask);
|
||||||
|
@ -41,6 +41,11 @@ void resetPin(u32 bank, u8 pin) {
|
||||||
u32 pinMask = 0x1 << (16 + pin);
|
u32 pinMask = 0x1 << (16 + pin);
|
||||||
SET_REG(GPIO_BSRR(bank), pinMask);
|
SET_REG(GPIO_BSRR(bank), pinMask);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
void gpio_write_bit(u32 bank, u8 pin, u8 val) {
|
||||||
|
val = !val; /* "set" bits are lower than "reset" bits */
|
||||||
|
SET_REG(GPIO_BSRR(bank), (1U << pin) << (16 * val));
|
||||||
|
}
|
||||||
|
|
||||||
bool readPin(u32 bank, u8 pin) {
|
bool readPin(u32 bank, u8 pin) {
|
||||||
// todo, implement read
|
// todo, implement read
|
||||||
|
@ -52,18 +57,18 @@ bool readPin(u32 bank, u8 pin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void strobePin(u32 bank, u8 pin, u8 count, u32 rate) {
|
void strobePin(u32 bank, u8 pin, u8 count, u32 rate) {
|
||||||
resetPin(bank, pin);
|
gpio_write_bit( bank,pin,0);
|
||||||
|
|
||||||
u32 c;
|
u32 c;
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
for (c = rate; c > 0; c--) {
|
for (c = rate; c > 0; c--) {
|
||||||
asm volatile("nop");
|
asm volatile("nop");
|
||||||
}
|
}
|
||||||
setPin(bank, pin);
|
gpio_write_bit( bank,pin,1);
|
||||||
for (c = rate; c > 0; c--) {
|
for (c = rate; c > 0; c--) {
|
||||||
asm volatile("nop");
|
asm volatile("nop");
|
||||||
}
|
}
|
||||||
resetPin(bank, pin);
|
gpio_write_bit( bank,pin,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +106,7 @@ void setupLED (void) {
|
||||||
|
|
||||||
/* Setup LED pin as output open drain */
|
/* Setup LED pin as output open drain */
|
||||||
SET_REG(LED_BANK_CR,(GET_REG(LED_BANK_CR) & LED_CR_MASK) | LED_CR_MODE);
|
SET_REG(LED_BANK_CR,(GET_REG(LED_BANK_CR) & LED_CR_MASK) | LED_CR_MODE);
|
||||||
setPin(LED_BANK, LED);
|
gpio_write_bit(LED_BANK, LED,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupBUTTON (void) {
|
void setupBUTTON (void) {
|
||||||
|
@ -110,7 +115,7 @@ void setupBUTTON (void) {
|
||||||
|
|
||||||
/* Setup button pin as floating input */
|
/* Setup button pin as floating input */
|
||||||
SET_REG(BUT_BANK_CR,(GET_REG(BUT_BANK_CR) & BUT_CR_MASK) | BUT_CR_OUTPUT_IN);
|
SET_REG(BUT_BANK_CR,(GET_REG(BUT_BANK_CR) & BUT_CR_MASK) | BUT_CR_OUTPUT_IN);
|
||||||
setPin(BUTTON_BANK, BUTTON);
|
gpio_write_bit(BUTTON_BANK, BUTTON,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupFLASH() {
|
void setupFLASH() {
|
||||||
|
|
|
@ -169,8 +169,10 @@ typedef struct {
|
||||||
} SCB_TypeDef;
|
} SCB_TypeDef;
|
||||||
|
|
||||||
|
|
||||||
void setPin(u32 bank, u8 pin);
|
//void setPin(u32 bank, u8 pin);
|
||||||
void resetPin(u32 bank, u8 pin);
|
//void resetPin(u32 bank, u8 pin);
|
||||||
|
void gpio_write_bit(u32 bank, u8 pin, u8 val);
|
||||||
|
|
||||||
bool readPin(u32 bank, u8 pin);
|
bool readPin(u32 bank, u8 pin);
|
||||||
void strobePin(u32 bank, u8 pin, u8 count, u32 rate);
|
void strobePin(u32 bank, u8 pin, u8 count, u32 rate);
|
||||||
|
|
||||||
|
|
|
@ -40,20 +40,20 @@ void setupUSB (void) {
|
||||||
/* Setup USB DISC pin as output open drain */
|
/* Setup USB DISC pin as output open drain */
|
||||||
SET_REG(USB_DISC_CR,
|
SET_REG(USB_DISC_CR,
|
||||||
(GET_REG(USB_DISC_CR) & USB_DISC_CR_MASK) | USB_DISC_CR_OUTPUT_OD);
|
(GET_REG(USB_DISC_CR) & USB_DISC_CR_MASK) | USB_DISC_CR_OUTPUT_OD);
|
||||||
setPin (USB_DISC_BANK,USB_DISC);
|
gpio_write_bit(USB_DISC_BANK,USB_DISC,1);
|
||||||
|
|
||||||
/* turn on the USB clock */
|
/* turn on the USB clock */
|
||||||
pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;
|
pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;
|
||||||
|
|
||||||
/* initialize the usb application */
|
/* initialize the usb application */
|
||||||
resetPin (USB_DISC_BANK,USB_DISC); /* present ourselves to the host */
|
gpio_write_bit(USB_DISC_BANK,USB_DISC,0); /* present ourselves to the host */
|
||||||
usbAppInit();
|
usbAppInit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void usbDsbBus(void) {
|
void usbDsbBus(void) {
|
||||||
setPin(USB_DISC_BANK,USB_DISC);
|
gpio_write_bit(USB_DISC_BANK,USB_DISC,1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue