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