[stm32f429-discovery] General sweep to fix style according to make stylecheck.

This commit is contained in:
Piotr Esden-Tempski
2015-02-04 20:39:32 -08:00
parent c06aba1603
commit 8c6eb9ca57
26 changed files with 1091 additions and 963 deletions

View File

@@ -41,10 +41,10 @@
* read by the program. See the README file for a discussion of
* the failure semantics.
*/
#define RECV_BUF_SIZE 128 // Arbitrary buffer size
#define RECV_BUF_SIZE 128 /* Arbitrary buffer size */
char recv_buf[RECV_BUF_SIZE];
volatile int recv_ndx_nxt; // Next place to store
volatile int recv_ndx_cur; // Next place to read
volatile int recv_ndx_nxt; /* Next place to store */
volatile int recv_ndx_cur; /* Next place to read */
/* For interrupt handling we add a new function which is called
* when recieve interrupts happen. The name (usart1_isr) is created
@@ -57,9 +57,10 @@ volatile int recv_ndx_cur; // Next place to read
* right or it won't work. And you'll wonder where your interrupts
* are going.
*/
void usart1_isr(void) {
uint32_t reg;
int i;
void usart1_isr(void)
{
uint32_t reg;
int i;
do {
reg = USART_SR(CONSOLE_UART);
@@ -68,21 +69,22 @@ void usart1_isr(void) {
#ifdef RESET_ON_CTRLC
/* Check for "reset" */
if (recv_buf[recv_ndx_nxt] == '\003') {
/* reset the system
* volatile definition of return address on the stack
* to insure it gets stored, changed to point to
* the trampoline function (do_the_nasty) which is
* required because we need to return of an interrupt
* to get the internal value of the LR register reset
* and put the processor back into "Thread" mode from
* "Handler" mode.
/* reset the system volatile definition of
* return address on the stack to insure it
* gets stored, changed to point to the
* trampoline function (do_the_nasty) which is
* required because we need to return of an
* interrupt to get the internal value of the
* LR register reset and put the processor back
* into "Thread" mode from "Handler" mode.
*
* See the PM0214 Programming Manual for Cortex M,
* pg 42, to see the format of the Cortex M4 stack after
* an interrupt or exception has occurred.
* See the PM0214 Programming Manual for Cortex
* M, pg 42, to see the format of the Cortex M4
* stack after an interrupt or exception has
* occurred.
*/
volatile uint32_t *ret = (&reg) + 7;
*ret = (uint32_t) &reset_handler;
return;
}
@@ -93,7 +95,8 @@ void usart1_isr(void) {
recv_ndx_nxt = i;
}
}
} while ((reg & USART_SR_RXNE) != 0); // can read back-to-back interrupts
} while ((reg & USART_SR_RXNE) != 0); /* can read back-to-back
interrupts */
}
/*
@@ -102,7 +105,8 @@ void usart1_isr(void) {
* Send the character 'c' to the USART, wait for the USART
* transmit buffer to be empty first.
*/
void console_putc(char c) {
void console_putc(char c)
{
uint32_t reg;
do {
reg = USART_SR(CONSOLE_UART);
@@ -120,10 +124,11 @@ void console_putc(char c) {
* The implementation is a bit different however, now it looks
* in the ring buffer to see if a character has arrived.
*/
char console_getc(int wait) {
char console_getc(int wait)
{
char c = 0;
while ((wait != 0) && (recv_ndx_cur == recv_ndx_nxt)) ;
while ((wait != 0) && (recv_ndx_cur == recv_ndx_nxt));
if (recv_ndx_cur != recv_ndx_nxt) {
c = recv_buf[recv_ndx_cur];
recv_ndx_cur = (recv_ndx_cur + 1) % RECV_BUF_SIZE;
@@ -138,7 +143,8 @@ char console_getc(int wait) {
* after the last character, as indicated by a NUL character, is
* reached.
*/
void console_puts(char *s) {
void console_puts(char *s)
{
while (*s != '\000') {
console_putc(*s);
/* Add in a carraige return, after sending line feed */
@@ -156,7 +162,8 @@ void console_puts(char *s) {
* support for editing characters (back space and delete)
* end when a <CR> character is received.
*/
int console_gets(char *s, int len) {
int console_gets(char *s, int len)
{
char *t = s;
char c;
@@ -179,7 +186,7 @@ int console_gets(char *s, int len) {
/* update end of string with NUL */
*t = '\000';
}
return (t - s);
return t - s;
}
/*
@@ -188,8 +195,8 @@ int console_gets(char *s, int len) {
* Set the pins and clocks to create a console that we can
* use for serial messages and getting text from the user.
*/
void console_setup(int baud) {
void console_setup(int baud)
{
/* MUST enable the GPIO clock in ADDITION to the USART clock */
rcc_periph_clock_enable(RCC_GPIOA);