Uncrustify.

This commit is contained in:
Maxim Salov 2014-01-04 17:27:24 -05:00 committed by Ian Martin
parent f576489c6e
commit 096ff72bd9
3 changed files with 118 additions and 119 deletions

29
main.c
View File

@ -5,24 +5,24 @@ volatile unsigned char ticks = 0;
volatile unsigned char flag_1hz = 0; volatile unsigned char flag_1hz = 0;
__attribute__((interrupt)) __attribute__((interrupt))
void wdti_handler(void) void
wdti_handler(void)
{ {
} }
__attribute__((interrupt)) __attribute__((interrupt))
void it_handler(void) void
it_handler(void)
{ {
++ticks; ++ticks;
LED1 ^= 1; LED1 ^= 1;
if (0 == (0x07 & ticks)) if(0 == (0x07 & ticks)) {
{
flag_1hz = 1; flag_1hz = 1;
} }
} }
int
int main(void) main(void)
{ {
asm("di"); asm ("di");
/* Setup LEDs */ /* Setup LEDs */
LED1 = 1; LED1 = 1;
LED2 = 1; LED2 = 1;
@ -34,8 +34,9 @@ int main(void)
CKC.ckc = 0x00U; CKC.ckc = 0x00U;
/* Delay 1 second */ /* Delay 1 second */
register unsigned long int i; register unsigned long int i;
for (i = 0x000FFFFFUL; i; --i) for(i = 0x000FFFFFUL; i; --i) {
asm("nop"); asm ("nop");
}
OSMC.osmc = 0x00; /* Supply fsub to peripherals, including Interval Timer */ OSMC.osmc = 0x00; /* Supply fsub to peripherals, including Interval Timer */
uart0_init(); uart0_init();
/* Setup 12-bit interval timer */ /* Setup 12-bit interval timer */
@ -47,15 +48,13 @@ int main(void)
ITIF = 0; /* Clear interrupt request flag */ ITIF = 0; /* Clear interrupt request flag */
ITMK = 0; /* Enable IT interrupt */ ITMK = 0; /* Enable IT interrupt */
asm ("ei"); /* Enable interrupts */ asm ("ei"); /* Enable interrupts */
for(;;) for(;;) {
{ if(flag_1hz) {
if (flag_1hz)
{
LED2 = 0; LED2 = 0;
flag_1hz = 0; flag_1hz = 0;
uart0_puts("Hello, RL78! [:"); uart0_puts("Hello, RL78! [:");
LED2 = 1; LED2 = 1;
} }
asm("halt"); asm ("halt");
} }
} }

32
uart0.c
View File

@ -2,7 +2,8 @@
#include <iodefine.h> #include <iodefine.h>
#include <iodefine_ext.h> #include <iodefine_ext.h>
void uart0_init(void) void
uart0_init(void)
{ {
/* Reference R01AN0459EJ0100 or hardware manual for details */ /* Reference R01AN0459EJ0100 or hardware manual for details */
PIOR.pior = 0U; /* Disable IO redirection */ PIOR.pior = 0U; /* Disable IO redirection */
@ -71,46 +72,45 @@ void uart0_init(void)
SS0.ss0 |= 0x03U; /* Enable UART0 operation (both channels) */ SS0.ss0 |= 0x03U; /* Enable UART0 operation (both channels) */
STIF0 = 1; /* Set buffer empty interrupt request flag */ STIF0 = 1; /* Set buffer empty interrupt request flag */
} }
int
int uart0_puts(const char __far * s) uart0_puts(const char __far *s)
{ {
int len = 0; int len = 0;
SMR00.smr00 |= 0x0001U; /* Set buffer empty interrupt */ SMR00.smr00 |= 0x0001U; /* Set buffer empty interrupt */
while ('\0' != *s) while('\0' != *s) {
{ while(0 == STIF0) ;
while (0 == STIF0);
STIF0 = 0; STIF0 = 0;
SDR00.sdr00 = *s++; SDR00.sdr00 = *s++;
++len; ++len;
} }
#if 0 #if 0
while (0 == STIF0); while(0 == STIF0) ;
STIF0 = 0; STIF0 = 0;
SDR00.sdr00 = '\r'; SDR00.sdr00 = '\r';
#endif #endif
while (0 == STIF0); while(0 == STIF0) ;
STIF0 = 0; STIF0 = 0;
SMR00.smr00 &= ~0x0001U; SMR00.smr00 &= ~0x0001U;
SDR00.sdr00 = '\n'; SDR00.sdr00 = '\n';
while (0 == STIF0); while(0 == STIF0) ;
#if 0 #if 0
while (0 != SSR00.BIT.bit6); /* Wait until TSF00 == 0 */ while(0 != SSR00.BIT.bit6) ; /* Wait until TSF00 == 0 */
#endif #endif
return len; return len;
} }
__attribute__((interrupt)) __attribute__((interrupt))
void st0_handler(void) void
st0_handler(void)
{ {
} }
__attribute__((interrupt)) __attribute__((interrupt))
void sr0_handler(void) void
sr0_handler(void)
{ {
} }
/* This is actually INTSRE0 interrupt handler */ /* This is actually INTSRE0 interrupt handler */
__attribute__((interrupt)) __attribute__((interrupt))
void tm01h_handler(void) void
tm01h_handler(void)
{ {
} }

View File

@ -2,6 +2,6 @@
#define UART0_H__ #define UART0_H__
void uart0_init(void); void uart0_init(void);
int uart0_puts(const char __far * s); int uart0_puts(const char __far *s);
#endif // UART0_H__ #endif /* UART0_H__ */