Skip to content

Commit 97950ac

Browse files
committed
Clean up some more indents
1 parent 64967a3 commit 97950ac

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

hardware.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool readPin(u32 bank, u8 pin) {
5959
bool readButtonState() {
6060
// todo, implement read
6161
bool state=FALSE;
62-
#if defined(BUTTON_BANK) && defined (BUTTON_PIN) && defined (BUTTON_PRESSED_STATE)
62+
#if defined(BUTTON_BANK) && defined (BUTTON_PIN) && defined (BUTTON_PRESSED_STATE)
6363
if (GET_REG(GPIO_IDR(BUTTON_BANK)) & (0x01 << BUTTON_PIN))
6464
{
6565
state = TRUE;
@@ -114,7 +114,7 @@ void setupCLK(void) {
114114
/* enable flash prefetch buffer */
115115
SET_REG(FLASH_ACR, 0x00000012);
116116

117-
/* Configure PLL */
117+
/* Configure PLL */
118118
#ifdef XTAL12M
119119
SET_REG(RCC_CFGR, GET_REG(RCC_CFGR) | 0x00110400); /* pll=72Mhz(x6),APB1=36Mhz,AHB=72Mhz */
120120
#else
@@ -125,7 +125,7 @@ void setupCLK(void) {
125125

126126

127127
#if !defined (HSE_STARTUP_TIMEOUT)
128-
#define HSE_STARTUP_TIMEOUT ((unsigned int)0x0500) /*!< Time out for HSE start up */
128+
#define HSE_STARTUP_TIMEOUT ((unsigned int)0x0500) /*!< Time out for HSE start up */
129129
#endif /* HSE_STARTUP_TIMEOUT */
130130

131131
while ((GET_REG(RCC_CR) & 0x03000000) == 0 && StartUpCounter < HSE_STARTUP_TIMEOUT)
@@ -149,14 +149,14 @@ void setupCLK(void) {
149149

150150

151151
void setupLEDAndButton (void) {
152-
// SET_REG(AFIO_MAPR,(GET_REG(AFIO_MAPR) & ~AFIO_MAPR_SWJ_CFG) | AFIO_MAPR_SWJ_CFG_NO_JTAG_NO_SW);// Try to disable SWD AND JTAG so we can use those pins (not sure if this works).
152+
// SET_REG(AFIO_MAPR,(GET_REG(AFIO_MAPR) & ~AFIO_MAPR_SWJ_CFG) | AFIO_MAPR_SWJ_CFG_NO_JTAG_NO_SW);// Try to disable SWD AND JTAG so we can use those pins (not sure if this works).
153153

154-
#if defined(BUTTON_BANK) && defined (BUTTON_PIN) && defined (BUTTON_PRESSED_STATE)
155-
SET_REG(GPIO_CR(BUTTON_BANK,BUTTON_PIN),(GPIO_CR(BUTTON_BANK,BUTTON_PIN) & crMask(BUTTON_PIN)) | CR_INPUT_PU_PD << CR_SHITF(BUTTON_PIN));
154+
#if defined(BUTTON_BANK) && defined (BUTTON_PIN) && defined (BUTTON_PRESSED_STATE)
155+
SET_REG(GPIO_CR(BUTTON_BANK,BUTTON_PIN),(GPIO_CR(BUTTON_BANK,BUTTON_PIN) & crMask(BUTTON_PIN)) | CR_INPUT_PU_PD << CR_SHITF(BUTTON_PIN));
156156

157-
gpio_write_bit(BUTTON_BANK, BUTTON_PIN,1-BUTTON_PRESSED_STATE);// set pulldown resistor in case there is no button.
158-
#endif
159-
SET_REG(GPIO_CR(LED_BANK,LED_PIN),(GET_REG(GPIO_CR(LED_BANK,LED_PIN)) & crMask(LED_PIN)) | CR_OUTPUT_PP << CR_SHITF(LED_PIN));
157+
gpio_write_bit(BUTTON_BANK, BUTTON_PIN,1-BUTTON_PRESSED_STATE);// set pulldown resistor in case there is no button.
158+
#endif
159+
SET_REG(GPIO_CR(LED_BANK,LED_PIN),(GET_REG(GPIO_CR(LED_BANK,LED_PIN)) & crMask(LED_PIN)) | CR_OUTPUT_PP << CR_SHITF(LED_PIN));
160160
}
161161

162162
void setupFLASH() {
@@ -182,20 +182,19 @@ bool checkUserCode(u32 usrAddr) {
182182
}
183183

184184
void setMspAndJump(u32 usrAddr) {
185-
// Dedicated function with no call to any function (appart the last call)
186-
// This way, there is no manipulation of the stack here, ensuring that GGC
187-
// didn't insert any pop from the SP after having set the MSP.
188-
typedef void (*funcPtr)(void);
189-
u32 jumpAddr = *(vu32 *)(usrAddr + 0x04); /* reset ptr in vector table */
185+
// Dedicated function with no call to any function (appart the last call)
186+
// This way, there is no manipulation of the stack here, ensuring that GGC
187+
// didn't insert any pop from the SP after having set the MSP.
188+
typedef void (*funcPtr)(void);
189+
u32 jumpAddr = *(vu32 *)(usrAddr + 0x04); /* reset ptr in vector table */
190190

191-
funcPtr usrMain = (funcPtr) jumpAddr;
191+
funcPtr usrMain = (funcPtr) jumpAddr;
192192

193-
SET_REG(SCB_VTOR, (vu32) (usrAddr));
193+
SET_REG(SCB_VTOR, (vu32) (usrAddr));
194194

195-
asm volatile("msr msp, %0"::"g"
196-
(*(volatile u32 *)usrAddr));
195+
asm volatile("msr msp, %0"::"g"(*(volatile u32 *)usrAddr));
197196

198-
usrMain(); /* go! */
197+
usrMain(); /* go! */
199198
}
200199

201200

usb.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,44 +40,43 @@ extern u8 u8_usbFunctionalDescriptor[];
4040
void setupUSB (void) {
4141

4242
#ifdef HAS_MAPLE_HARDWARE
43-
/* Setup USB DISC pin as output open drain */
44-
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_OD << CR_SHITF(USB_DISC_PIN));
45-
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,1);
43+
/* Setup USB DISC pin as output open drain */
44+
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_OD << CR_SHITF(USB_DISC_PIN));
45+
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,1);
4646

47-
/* turn on the USB clock */
48-
//pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;// done in setupCLK()
47+
/* turn on the USB clock */
48+
//pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;// done in setupCLK()
4949

50-
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
50+
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
5151
#else
5252

5353
/* Generic boards don't have disconnect hardware, so we drive PA12 which is connected to the usb D+ line*/
5454
#define USB_DISC_BANK GPIOA
5555
#define USB_DISC_PIN 12
5656

57-
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),
58-
(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_PP << CR_SHITF(USB_DISC_PIN));
57+
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_PP << CR_SHITF(USB_DISC_PIN));
5958

60-
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
59+
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
6160

62-
volatile unsigned int delay;
63-
for(delay = 0;delay<512;delay++);
61+
volatile unsigned int delay;
62+
for(delay = 0;delay<512;delay++);
6463

65-
// volatile unsigned x = 1024; do { ; }while(--x);// wait a moment
66-
/* turn on the USB clock */
67-
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),
68-
(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_INPUT << CR_SHITF(USB_DISC_PIN)); //Sets the PA12 as floating input
69-
// pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;
64+
// volatile unsigned x = 1024; do { ; }while(--x);// wait a moment
65+
/* turn on the USB clock */
66+
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),
67+
(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_INPUT << CR_SHITF(USB_DISC_PIN)); //Sets the PA12 as floating input
68+
// pRCC->APB1ENR |= RCC_APB1ENR_USB_CLK;
7069
#endif
71-
/* initialize the usb application */
70+
/* initialize the usb application */
7271

73-
wTransferSize=getFlashPageSize();
74-
u8_usbConfigDescriptorDFU[41]=(wTransferSize & 0x00FF);
75-
u8_usbConfigDescriptorDFU[42]=(wTransferSize & 0xFF00)>>8;
72+
wTransferSize=getFlashPageSize();
73+
u8_usbConfigDescriptorDFU[41]=(wTransferSize & 0x00FF);
74+
u8_usbConfigDescriptorDFU[42]=(wTransferSize & 0xFF00)>>8;
7675

77-
u8_usbFunctionalDescriptor[5]=(wTransferSize & 0x00FF);
78-
u8_usbFunctionalDescriptor[6]=(wTransferSize & 0xFF00)>>8;
76+
u8_usbFunctionalDescriptor[5]=(wTransferSize & 0x00FF);
77+
u8_usbFunctionalDescriptor[6]=(wTransferSize & 0xFF00)>>8;
7978

80-
usbAppInit();
79+
usbAppInit();
8180

8281
}
8382

0 commit comments

Comments
 (0)