First coarse run to fix coding style in locm3.
Added --terse and --mailback options to the make stylecheck target. It also does continue even if it enounters a possible error. We decided on two exceptions from the linux kernel coding standard: - Empty wait while loops may end with ; on the same line. - All blocks after while, if, for have to be in brackets even if they only contain one statement. Otherwise it is easy to introduce an error. Checkpatch needs to be adapted to reflect those changes.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
void __attribute__((weak)) cm3_assert_failed(void)
|
||||
{
|
||||
while(1);
|
||||
while (1);
|
||||
}
|
||||
|
||||
void __attribute__((weak)) cm3_assert_failed_verbose(
|
||||
|
||||
@@ -45,7 +45,7 @@ LGPL License Terms @ref lgpl_license
|
||||
#include <libopencm3/cm3/nvic.h>
|
||||
#include <libopencm3/cm3/scs.h>
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Enable Interrupt
|
||||
|
||||
Enables a user interrupt.
|
||||
@@ -58,7 +58,7 @@ void nvic_enable_irq(u8 irqn)
|
||||
NVIC_ISER(irqn / 32) = (1 << (irqn % 32));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Disable Interrupt
|
||||
|
||||
Disables a user interrupt.
|
||||
@@ -71,7 +71,7 @@ void nvic_disable_irq(u8 irqn)
|
||||
NVIC_ICER(irqn / 32) = (1 << (irqn % 32));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Return Pending Interrupt
|
||||
|
||||
True if the interrupt has occurred and is waiting for service.
|
||||
@@ -85,7 +85,7 @@ u8 nvic_get_pending_irq(u8 irqn)
|
||||
return NVIC_ISPR(irqn / 32) & (1 << (irqn % 32)) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Set Pending Interrupt
|
||||
|
||||
Force a user interrupt to a pending state. This has no effect if the interrupt
|
||||
@@ -99,7 +99,7 @@ void nvic_set_pending_irq(u8 irqn)
|
||||
NVIC_ISPR(irqn / 32) = (1 << (irqn % 32));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Clear Pending Interrupt
|
||||
|
||||
Force remove a user interrupt from a pending state. This has no effect if the
|
||||
@@ -113,7 +113,7 @@ void nvic_clear_pending_irq(u8 irqn)
|
||||
NVIC_ICPR(irqn / 32) = (1 << (irqn % 32));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Return Active Interrupt
|
||||
|
||||
Interrupt has occurred and is currently being serviced.
|
||||
@@ -127,7 +127,7 @@ u8 nvic_get_active_irq(u8 irqn)
|
||||
return NVIC_IABR(irqn / 32) & (1 << (irqn % 32)) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Return Enabled Interrupt
|
||||
|
||||
@param[in] irqn Unsigned int8. Interrupt number @ref nvic_stm32f1_userint
|
||||
@@ -139,13 +139,14 @@ u8 nvic_get_irq_enabled(u8 irqn)
|
||||
return NVIC_ISER(irqn / 32) & (1 << (irqn % 32)) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Set Interrupt Priority
|
||||
|
||||
There are 16 priority levels only, given by the upper four bits of the priority
|
||||
byte, as required by ARM standards. The priority levels are interpreted according
|
||||
to the pre-emptive priority grouping set in the SCB Application Interrupt and Reset
|
||||
Control Register (SCB_AIRCR), as done in @ref scb_set_priority_grouping.
|
||||
byte, as required by ARM standards. The priority levels are interpreted
|
||||
according to the pre-emptive priority grouping set in the SCB Application
|
||||
Interrupt and Reset Control Register (SCB_AIRCR), as done in @ref
|
||||
scb_set_priority_grouping.
|
||||
|
||||
@param[in] irqn Unsigned int8. Interrupt number @ref nvic_stm32f1_userint
|
||||
@param[in] priority Unsigned int8. Interrupt priority (0 ... 255 in steps of 16)
|
||||
@@ -156,29 +157,29 @@ void nvic_set_priority(u8 irqn, u8 priority)
|
||||
/* code from lpc43xx/nvic.c -- this is quite a hack and alludes to the
|
||||
* negative interrupt numbers assigned to the system interrupts. better
|
||||
* handling would mean signed integers. */
|
||||
if(irqn>=NVIC_IRQ_COUNT)
|
||||
{
|
||||
if (irqn >= NVIC_IRQ_COUNT) {
|
||||
/* Cortex-M system interrupts */
|
||||
SCS_SHPR( (irqn&0xF)-4 ) = priority;
|
||||
}else
|
||||
{
|
||||
SCS_SHPR((irqn & 0xF) - 4) = priority;
|
||||
} else {
|
||||
/* Device specific interrupts */
|
||||
NVIC_IPR(irqn) = priority;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief NVIC Software Trigger Interrupt
|
||||
|
||||
Generate an interrupt from software. This has no effect for unprivileged access
|
||||
unless the privilege level has been elevated through the System Control Registers.
|
||||
unless the privilege level has been elevated through the System Control
|
||||
Registers.
|
||||
|
||||
@param[in] irqn Unsigned int16. Interrupt number (0 ... 239)
|
||||
*/
|
||||
|
||||
void nvic_generate_software_interrupt(u16 irqn)
|
||||
{
|
||||
if (irqn <= 239)
|
||||
if (irqn <= 239) {
|
||||
NVIC_STIR |= irqn;
|
||||
}
|
||||
}
|
||||
/**@}*/
|
||||
|
||||
@@ -25,14 +25,14 @@ void scb_reset_core(void)
|
||||
{
|
||||
SCB_AIRCR = SCB_AIRCR_VECTKEY | SCB_AIRCR_VECTRESET;
|
||||
|
||||
while(1);
|
||||
while (1);
|
||||
}
|
||||
|
||||
void scb_reset_system(void)
|
||||
{
|
||||
SCB_AIRCR = SCB_AIRCR_VECTKEY | SCB_AIRCR_SYSRESETREQ;
|
||||
|
||||
while(1);
|
||||
while (1);
|
||||
}
|
||||
|
||||
void scb_set_priority_grouping(u32 prigroup)
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
|
||||
#include <libopencm3/cm3/sync.h>
|
||||
|
||||
u32 __ldrex(volatile u32* addr)
|
||||
u32 __ldrex(volatile u32 *addr)
|
||||
{
|
||||
u32 res;
|
||||
__asm__ volatile ("ldrex %0, [%1]" : "=r" (res) : "r" (addr));
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 __strex(u32 val, volatile u32* addr)
|
||||
u32 __strex(u32 val, volatile u32 *addr)
|
||||
{
|
||||
u32 res;
|
||||
__asm__ volatile ("strex %0, %2, [%1]" :
|
||||
"=&r" (res) : "r" (addr), "r" (val));
|
||||
__asm__ volatile ("strex %0, %2, [%1]"
|
||||
: "=&r" (res) : "r" (addr), "r" (val));
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ void __dmb()
|
||||
__asm__ volatile ("dmb");
|
||||
}
|
||||
|
||||
void mutex_lock(mutex_t* m)
|
||||
void mutex_lock(mutex_t *m)
|
||||
{
|
||||
u32 status = 0;
|
||||
|
||||
@@ -57,7 +57,7 @@ void mutex_lock(mutex_t* m)
|
||||
__dmb();
|
||||
}
|
||||
|
||||
void mutex_unlock(mutex_t* m)
|
||||
void mutex_unlock(mutex_t *m)
|
||||
{
|
||||
__dmb();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ LGPL License Terms @ref lgpl_license
|
||||
/**@{*/
|
||||
#include <libopencm3/cm3/systick.h>
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief SysTick Set the Automatic Reload Value.
|
||||
|
||||
The counter is set to the reload value when the counter starts and after it
|
||||
@@ -54,7 +54,7 @@ void systick_set_reload(u32 value)
|
||||
STK_LOAD = (value & 0x00FFFFFF);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief SysTick Read the Automatic Reload Value.
|
||||
|
||||
@returns 24 bit reload value as u32.
|
||||
@@ -62,10 +62,10 @@ void systick_set_reload(u32 value)
|
||||
|
||||
u32 systick_get_reload(void)
|
||||
{
|
||||
return (STK_LOAD & 0x00FFFFFF);
|
||||
return STK_LOAD & 0x00FFFFFF;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Get the current SysTick counter value.
|
||||
|
||||
@returns 24 bit current value as u32.
|
||||
@@ -73,10 +73,10 @@ u32 systick_get_reload(void)
|
||||
|
||||
u32 systick_get_value(void)
|
||||
{
|
||||
return (STK_VAL & 0x00FFFFFF);
|
||||
return STK_VAL & 0x00FFFFFF;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Set the SysTick Clock Source.
|
||||
|
||||
The clock source can be either the AHB clock or the same clock divided by 8.
|
||||
@@ -86,11 +86,12 @@ The clock source can be either the AHB clock or the same clock divided by 8.
|
||||
|
||||
void systick_set_clocksource(u8 clocksource)
|
||||
{
|
||||
if (clocksource < 2)
|
||||
if (clocksource < 2) {
|
||||
STK_CTRL |= (clocksource << STK_CTRL_CLKSOURCE_LSB);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Enable SysTick Interrupt.
|
||||
|
||||
*/
|
||||
@@ -100,7 +101,7 @@ void systick_interrupt_enable(void)
|
||||
STK_CTRL |= STK_CTRL_TICKINT;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Disable SysTick Interrupt.
|
||||
|
||||
*/
|
||||
@@ -110,7 +111,7 @@ void systick_interrupt_disable(void)
|
||||
STK_CTRL &= ~STK_CTRL_TICKINT;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Enable SysTick Counter.
|
||||
|
||||
*/
|
||||
@@ -120,7 +121,7 @@ void systick_counter_enable(void)
|
||||
STK_CTRL |= STK_CTRL_ENABLE;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Disable SysTick Counter.
|
||||
|
||||
*/
|
||||
@@ -130,31 +131,32 @@ void systick_counter_disable(void)
|
||||
STK_CTRL &= ~STK_CTRL_ENABLE;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief SysTick Read the Counter Flag.
|
||||
|
||||
The count flag is set when the timer count becomes zero, and is cleared when the
|
||||
flag is read.
|
||||
The count flag is set when the timer count becomes zero, and is cleared when
|
||||
the flag is read.
|
||||
|
||||
@returns Boolean if flag set.
|
||||
*/
|
||||
|
||||
u8 systick_get_countflag(void)
|
||||
{
|
||||
if (STK_CTRL & STK_CTRL_COUNTFLAG)
|
||||
if (STK_CTRL & STK_CTRL_COUNTFLAG) {
|
||||
return 1;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief SysTick Get Calibration Value
|
||||
|
||||
@returns Current calibration value
|
||||
*/
|
||||
u32 systick_get_calib(void)
|
||||
{
|
||||
return (STK_CALIB&0x00FFFFFF);
|
||||
return STK_CALIB & 0x00FFFFFF;
|
||||
}
|
||||
/**@}*/
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
/* load the weak symbols for IRQ_HANDLERS */
|
||||
#include "../dispatch/vector_nvic.c"
|
||||
|
||||
#define WEAK __attribute__ ((weak))
|
||||
|
||||
/* Symbols exported by the linker script(s): */
|
||||
extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack;
|
||||
typedef void (*funcp_t) (void);
|
||||
@@ -61,17 +59,23 @@ void WEAK __attribute__ ((naked)) reset_handler(void)
|
||||
volatile unsigned *src, *dest;
|
||||
funcp_t *fp;
|
||||
|
||||
for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++)
|
||||
for (src = &_data_loadaddr, dest = &_data;
|
||||
dest < &_edata;
|
||||
src++, dest++) {
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
while (dest < &_ebss)
|
||||
while (dest < &_ebss) {
|
||||
*dest++ = 0;
|
||||
}
|
||||
|
||||
/* Constructors. */
|
||||
for (fp = &__preinit_array_start; fp < &__preinit_array_end; fp++)
|
||||
(*fp)();
|
||||
for (fp = &__init_array_start; fp < &__init_array_end; fp++)
|
||||
(*fp)();
|
||||
for (fp = &__preinit_array_start; fp < &__preinit_array_end; fp++) {
|
||||
(*fp)();
|
||||
}
|
||||
for (fp = &__init_array_start; fp < &__init_array_end; fp++) {
|
||||
(*fp)();
|
||||
}
|
||||
|
||||
/* might be provided by platform specific vector.c */
|
||||
pre_main();
|
||||
@@ -80,13 +84,15 @@ void WEAK __attribute__ ((naked)) reset_handler(void)
|
||||
main();
|
||||
|
||||
/* Destructors. */
|
||||
for (fp = &__fini_array_start; fp < &__fini_array_end; fp++)
|
||||
(*fp)();
|
||||
for (fp = &__fini_array_start; fp < &__fini_array_end; fp++) {
|
||||
(*fp)();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void blocking_handler(void)
|
||||
{
|
||||
while (1) ;
|
||||
while (1);
|
||||
}
|
||||
|
||||
void null_handler(void)
|
||||
|
||||
Reference in New Issue
Block a user