Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
test_mc_asctec_v1_simple.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
24 /*
25  *
26  * That would be a quick asctech protocol test
27  *
28  */
29 
30 
31 #include "mcu.h"
32 #include "mcu_periph/sys_time.h"
34 #include "led.h"
35 
36 static inline void main_init( void );
37 static inline void main_periodic_task( void );
38 static inline void main_event_task( void );
39 
41 
42 int main(void) {
43  main_init();
44 
45  while(1) {
49  }
50 
51  return 0;
52 }
53 
54 static inline void main_init( void ) {
55  mcu_init();
57 }
58 
59 
60 
61 static inline void main_periodic_task( void ) {
62 
63 
64  RunOnceEvery(256, {DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);});
65  RunOnceEvery(256,
66  {
67  uint16_t i2c1_ack_fail_cnt = i2c1.errors->ack_fail_cnt;
68  uint16_t i2c1_miss_start_stop_cnt = i2c1.errors->miss_start_stop_cnt;
69  uint16_t i2c1_arb_lost_cnt = i2c1.errors->arb_lost_cnt;
70  uint16_t i2c1_over_under_cnt = i2c1.errors->over_under_cnt;
71  uint16_t i2c1_pec_recep_cnt = i2c1.errors->pec_recep_cnt;
72  uint16_t i2c1_timeout_tlow_cnt = i2c1.errors->timeout_tlow_cnt;
73  uint16_t i2c1_smbus_alert_cnt = i2c1.errors->smbus_alert_cnt;
74  uint16_t i2c1_unexpected_event_cnt = i2c1.errors->unexpected_event_cnt;
75  uint32_t i2c1_last_unexpected_event = i2c1.errors->last_unexpected_event;
76  const uint8_t _bus1 = 1;
77  DOWNLINK_SEND_I2C_ERRORS(DefaultChannel, DefaultDevice,
78  &i2c1_ack_fail_cnt,
79  &i2c1_miss_start_stop_cnt,
80  &i2c1_arb_lost_cnt,
81  &i2c1_over_under_cnt,
82  &i2c1_pec_recep_cnt,
83  &i2c1_timeout_tlow_cnt,
84  &i2c1_smbus_alert_cnt,
85  &i2c1_unexpected_event_cnt,
86  &i2c1_last_unexpected_event,
87  &_bus1);
88  });
89 
90 
91  i2c1_buf[0] = 100 + 0;
92  i2c1_buf[1] = 100 + 0;
93  i2c1_buf[2] = 100 + 0;
94  i2c1_buf[3] = 6;
95  i2c1_transmit(0x02, 4, &i2c_done);
96 
97  LED_PERIODIC();
98 
99 }
100 
101 
102 
103 static inline void main_event_task( void ) {
104 
105 }
static void main_periodic_task(void)
unsigned short uint16_t
Definition: types.h:16
static void main_init(void)
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
Architecture independent timing functions.
unsigned long uint32_t
Definition: types.h:18
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:35
static bool_t sys_time_check_and_ack_timer(tid_t id)
Definition: sys_time.h:90
#define LED_PERIODIC()
Definition: led_hw.h:8
arch independent mcu ( Micro Controller Unit ) utilities
unsigned char uint8_t
Definition: types.h:14
static uint8_t i2c_done
int main(void)
arch independent LED (Light Emitting Diodes) API
static void main_event_task(void)
void mcu_init(void)
Definition: mcu.c:57