aboutsummaryrefslogtreecommitdiff
path: root/examples/obldc/can/can.c
diff options
context:
space:
mode:
authorUwe Hermann2010-12-26 00:34:14 +0100
committerUwe Hermann2010-12-26 00:36:32 +0100
commit571c4d37d02e9dd54a65241aec549e7e0875b01b (patch)
tree5028565f6d422f98165f6db0ba3f01e71f97f61e /examples/obldc/can/can.c
parent06d1a5ca80e81b06d430201923d4002b7eb6ebe8 (diff)
CAN: Reduce nesting level via code transformations.
Diffstat (limited to 'examples/obldc/can/can.c')
-rw-r--r--examples/obldc/can/can.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/examples/obldc/can/can.c b/examples/obldc/can/can.c
index 881a185..d96d1c9 100644
--- a/examples/obldc/can/can.c
+++ b/examples/obldc/can/can.c
@@ -150,26 +150,25 @@ void sys_tick_handler(void)
static int temp32 = 0;
static u8 data[8] = {0, 1, 2, 0, 0, 0, 0, 0};
- temp32++;
-
/* We call this handler every 1ms so 1000ms = 1s on/off. */
- if (temp32 == 1000) {
- temp32 = 0;
-
- /* Transmit CAN frame. */
- data[0]++;
- if (can_transmit(CAN1,
- 0, /* (EX/ST)ID: CAN ID */
- false, /* IDE: CAN ID extended? */
- false, /* RTR: Request transmit? */
- 8, /* DLC: Data length */
- data) == -1)
- {
- gpio_set(GPIOA, GPIO6); /* LED0 off */
- gpio_set(GPIOA, GPIO7); /* LED1 off */
- gpio_clear(GPIOB, GPIO0); /* LED2 on */
- gpio_set(GPIOB, GPIO1); /* LED3 off */
- }
+ if (++temp32 != 1000)
+ return;
+
+ temp32 = 0;
+
+ /* Transmit CAN frame. */
+ data[0]++;
+ if (can_transmit(CAN1,
+ 0, /* (EX/ST)ID: CAN ID */
+ false, /* IDE: CAN ID extended? */
+ false, /* RTR: Request transmit? */
+ 8, /* DLC: Data length */
+ data) == -1)
+ {
+ gpio_set(GPIOA, GPIO6); /* LED0 off */
+ gpio_set(GPIOA, GPIO7); /* LED1 off */
+ gpio_clear(GPIOB, GPIO0); /* LED2 on */
+ gpio_set(GPIOB, GPIO1); /* LED3 off */
}
}