other/*: Random coding-style fixes.
This commit is contained in:
parent
8a77630997
commit
7f1e75c3a8
@ -37,11 +37,11 @@ void gpio_setup(void)
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
|
||||
}
|
||||
|
||||
void sys_tick_handler()
|
||||
void sys_tick_handler(void)
|
||||
{
|
||||
temp32++;
|
||||
|
||||
/* we call this handler every 1ms so 1000ms = 1s on/off */
|
||||
/* We call this handler every 1ms so 1000ms = 1s on/off. */
|
||||
if (temp32 == 1000) {
|
||||
gpio_toggle(GPIOB, GPIO6); /* LED2 on/off */
|
||||
temp32 = 0;
|
||||
@ -66,7 +66,7 @@ int main(void)
|
||||
|
||||
systick_interrupt_enable();
|
||||
|
||||
/* start counting */
|
||||
/* Start counting. */
|
||||
systick_counter_enable();
|
||||
|
||||
while (1); /* Halt. */
|
||||
|
@ -35,20 +35,17 @@ void gpio_setup(void)
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
|
||||
}
|
||||
|
||||
void nvic_setup()
|
||||
void nvic_setup(void)
|
||||
{
|
||||
/* without this the timer interrupt routine will never be called */
|
||||
/* Without this the timer interrupt routine will never be called. */
|
||||
nvic_enable_irq(NVIC_TIM2_IRQ);
|
||||
nvic_set_priority(NVIC_TIM2_IRQ, 1);
|
||||
}
|
||||
|
||||
void tim2_isr()
|
||||
void tim2_isr(void)
|
||||
{
|
||||
/* LED2 on/off */
|
||||
gpio_toggle(GPIOB, GPIO6);
|
||||
|
||||
/* clear interrrupt flag */
|
||||
TIM_SR(TIM2) &= ~TIM_SR_UIF;
|
||||
gpio_toggle(GPIOB, GPIO6); /* LED2 on/off. */
|
||||
TIM_SR(TIM2) &= ~TIM_SR_UIF; /* Clear interrrupt flag. */
|
||||
}
|
||||
|
||||
int main(void)
|
||||
@ -62,21 +59,24 @@ int main(void)
|
||||
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM2EN);
|
||||
|
||||
/* the goal is to let the LED2 glow for a second and then be off for a second */
|
||||
/*
|
||||
* The goal is to let the LED2 glow for a second and then be
|
||||
* off for a second.
|
||||
*/
|
||||
|
||||
/* Set timer start value */
|
||||
/* Set timer start value. */
|
||||
TIM_CNT(TIM2) = 1;
|
||||
|
||||
/* Set timer prescaler. 72MHz/1440 => 50000 counts per second */
|
||||
/* Set timer prescaler. 72MHz/1440 => 50000 counts per second. */
|
||||
TIM_PSC(TIM2) = 1440;
|
||||
|
||||
/* End timer value. If this value is reached an interrupt is generated */
|
||||
/* End timer value. If this is reached an interrupt is generated. */
|
||||
TIM_ARR(TIM2) = 50000;
|
||||
|
||||
/* Update interrupt enable */
|
||||
/* Update interrupt enable. */
|
||||
TIM_DIER(TIM2) |= TIM_DIER_UIE;
|
||||
|
||||
/* Start timer */
|
||||
/* Start timer. */
|
||||
TIM_CR1(TIM2) |= TIM_CR1_CEN;
|
||||
|
||||
while (1); /* Halt. */
|
||||
|
@ -40,9 +40,11 @@ static const struct usb_device_descriptor dev = {
|
||||
.bNumConfigurations = 1,
|
||||
};
|
||||
|
||||
/* This notification endpoint isn't implemented. According to CDC spec its
|
||||
* optional, but its absence causes a NULL pointer dereference in Linux cdc_acm
|
||||
* driver. */
|
||||
/*
|
||||
* This notification endpoint isn't implemented. According to CDC spec its
|
||||
* optional, but its absence causes a NULL pointer dereference in Linux
|
||||
* cdc_acm driver.
|
||||
*/
|
||||
static const struct usb_endpoint_descriptor comm_endp[] = {{
|
||||
.bLength = USB_DT_ENDPOINT_SIZE,
|
||||
.bDescriptorType = USB_DT_ENDPOINT,
|
||||
@ -159,7 +161,7 @@ static const char *usb_strings[] = {
|
||||
"x",
|
||||
"Black Sphere Technologies",
|
||||
"CDC-ACM Demo",
|
||||
"DEMO"
|
||||
"DEMO",
|
||||
};
|
||||
|
||||
static int cdcacm_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
@ -170,13 +172,15 @@ static int cdcacm_control_request(struct usb_setup_data *req, u8 **buf,
|
||||
|
||||
switch(req->bRequest) {
|
||||
case USB_CDC_REQ_SET_CONTROL_LINE_STATE: {
|
||||
/* This Linux cdc_acm driver requires this to be implemented
|
||||
/*
|
||||
* This Linux cdc_acm driver requires this to be implemented
|
||||
* even though it's optional in the CDC spec, and we don't
|
||||
* advertise it in the ACM functional descriptor. */
|
||||
* advertise it in the ACM functional descriptor.
|
||||
*/
|
||||
char buf[10];
|
||||
struct usb_cdc_notification *notif = (void *)buf;
|
||||
|
||||
/* We echo signals back to host as notification */
|
||||
/* We echo signals back to host as notification. */
|
||||
notif->bmRequestType = 0xA1;
|
||||
notif->bNotification = USB_CDC_NOTIFY_SERIAL_STATE;
|
||||
notif->wValue = 0;
|
||||
@ -202,6 +206,7 @@ static void cdcacm_data_rx_cb(u8 ep)
|
||||
|
||||
char buf[64];
|
||||
int len = usbd_ep_read_packet(0x01, buf, 64);
|
||||
|
||||
if (len) {
|
||||
usbd_ep_write_packet(0x82, buf, len);
|
||||
buf[len] = 0;
|
||||
|
@ -111,7 +111,7 @@ static const char *usb_strings[] = {
|
||||
"DFU Demo",
|
||||
"DEMO",
|
||||
/* This string is used by ST Microelectronics' DfuSe utility. */
|
||||
"@Internal Flash /0x08000000/8*001Ka,56*001Kg"
|
||||
"@Internal Flash /0x08000000/8*001Ka,56*001Kg",
|
||||
};
|
||||
|
||||
static u8 usbdfu_getstatus(u32 *bwPollTimeout)
|
||||
|
@ -60,7 +60,7 @@ static const u8 hid_report_descriptor[] = {
|
||||
0x81, 0x06, 0xC0, 0x09, 0x3c, 0x05, 0xff, 0x09,
|
||||
0x01, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95,
|
||||
0x02, 0xb1, 0x22, 0x75, 0x06, 0x95, 0x01, 0xb1,
|
||||
0x01, 0xc0
|
||||
0x01, 0xc0,
|
||||
};
|
||||
|
||||
static const struct {
|
||||
@ -179,7 +179,7 @@ static int hid_control_request(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
(req->wValue != 0x2200))
|
||||
return 0;
|
||||
|
||||
/* Handle the HID report descriptor */
|
||||
/* Handle the HID report descriptor. */
|
||||
*buf = (u8 *)hid_report_descriptor;
|
||||
*len = sizeof(hid_report_descriptor);
|
||||
|
||||
@ -205,7 +205,7 @@ static int dfu_control_request(struct usb_setup_data *req, u8 **buf, u16 *len,
|
||||
(void)len;
|
||||
|
||||
if ((req->bmRequestType != 0x21) || (req->bRequest != DFU_DETACH))
|
||||
return 0; /* Only accept class request */
|
||||
return 0; /* Only accept class request. */
|
||||
|
||||
*complete = dfu_detach_complete;
|
||||
|
||||
@ -265,8 +265,10 @@ void sys_tick_handler(void)
|
||||
|
||||
buf[1] = dir;
|
||||
x += dir;
|
||||
if(x > 30) dir = -dir;
|
||||
if(x < -30) dir = -dir;
|
||||
if (x > 30)
|
||||
dir = -dir;
|
||||
if (x < -30)
|
||||
dir = -dir;
|
||||
|
||||
usbd_ep_write_packet(0x81, buf, 4);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user