Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
humid_pcap01.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011 Norman Wildmann, Martin Mueller
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
31#include "led.h"
32#include "mcu_periph/sys_time.h"
33#include "mcu_periph/i2c.h"
34#include "mcu_periph/uart.h"
35#include "pprzlink/messages.h"
38#ifdef PCAP01_LOAD_FIRMWARE
39#include "modules/meteo/humid_pcap01_firmware.h"
40#endif
41
42
46
47#ifndef PCAP01_I2C_DEV
48#define PCAP01_I2C_DEV i2c0
49#endif
50
52{
54
55 pcap01_trans.buf[0] = 0x90 + (unsigned char)(s_add >> 8);
56 pcap01_trans.buf[1] = (unsigned char)(s_add);
57 pcap01_trans.buf[2] = data;
59}
60
62{
64
65 pcap01_trans.buf[0] = 0x10 + (unsigned char)(s_add >> 8);
66 pcap01_trans.buf[1] = (unsigned char)(s_add);
69
70 return pcap01_trans.buf[0];
71}
95
97{
99
101 pcap01_trans.buf[1] = (unsigned char)(value >> 16);
102 pcap01_trans.buf[2] = (unsigned char)(value >> 8);
103 pcap01_trans.buf[3] = (unsigned char)(value);
105}
106
107#ifdef PCAP01_LOAD_FIRMWARE
108void writePCAP01_firmware(void)
109{
110 int i = 0;
111 char testbyte = 44;
113 // Hard reset
115 sys_time_usleep(50000);
116 //write testbyte
118
119 //check testbyte
121 return;
122 } else {
123 LED_ON(3);
124 //Hard reset
126 //write firmware
127 for (i = 0; i < sizeof(firmware); i++) {
129 }
130 //fill with ffs
131 for (; i < 4029; i++) {
132 writePCAP01_SRAM(0xff, i);
133 }
134 i++;
135#ifdef PCAP01_200HZ
136 //write end bytes of sram
137 writePCAP01_SRAM(0x04, i++);
138 writePCAP01_SRAM(0x01, i++);
139 writePCAP01_SRAM(0x01, i++);
140#endif
141#ifdef PCAP01_STANDARD
142 //write end bytes of sram
143 writePCAP01_SRAM(0x02, i++);
144 writePCAP01_SRAM(0x01, i++);
145 writePCAP01_SRAM(0x03, i++);
146#endif
147 }
148}
149#endif // PCAP01_LOAD_FIRMWARE
150
151void pcap01_init(void)
152{
155#ifdef PCAP01_LOAD_FIRMWARE
157#endif
180 sys_time_usleep(500000);
182}
183
190
198{
200#ifdef PCAP01_STANDARD
202#endif
203#ifdef PCAP01_200HZ
205#endif
206}
207
208void pcap01_event(void)
209{
210 float humidity;
211 float temperature;
212
214 switch (pcap01Value.status) {
215
216 case PCAP01_GET_HUMID:
218 pcap01Value.C_ratio |= (pcap01_trans.buf[1] << 8);
221#ifdef PCAP01_STANDARD
223#endif
224#ifdef PCAP01_200HZ
226#endif
227 break;
228
229 case PCAP01_GET_TEMP:
231 pcap01Value.R_ratio |= (pcap01_trans.buf[1] << 8);
233 humidity = pcap01Value.C_ratio * (-0.0023959245437) + 516.4124438673063;
234 temperature = pcap01Value.R_ratio * 61.927 - 259.74;
238 &humidity,
239 &temperature);
242 break;
243
244 default:
246 break;
247 }
248 }
249}
#define LED_ON(i)
Definition led_hw.h:51
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
Definition i2c.h:122
enum I2CTransactionStatus status
Transaction status.
Definition i2c.h:126
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
Definition i2c.c:202
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
Definition i2c.c:222
@ I2CTransSuccess
transaction successfully finished by I2C driver
Definition i2c.h:57
@ I2CTransDone
transaction set to done by user level
Definition i2c.h:59
@ I2CTransPending
transaction is pending in queue
Definition i2c.h:55
I2C transaction structure.
Definition i2c.h:93
PCAP01VALUE pcap01Value
void pcap01_periodic(void)
pcap01_readData
void PCAP01_Control(uint8_t control)
PCAP01_Control.
void pcap01readRegister(uint8_t reg)
void pcap01_event(void)
void pcap01_init(void)
void pcap01writeRegister(uint8_t reg, uint32_t value)
void writePCAP01_SRAM(uint8_t data, uint16_t s_add)
struct i2c_transaction pcap01_trans
uint8_t readPCAP01_SRAM(uint16_t s_add)
#define PCAP01_I2C_DEV
uint8_t pcap01_meas_started
ACAM Picocap Single-chip Solution for Capacitance Measurement.
#define PCAP01_REG18_VALUE
#define PCAP01_REG6_VALUE
#define PCAP01_REG8_VALUE
#define PCAP01_WRITE_REG
uint32_t C_ratio
#define PCAP01_IN_RESET
#define PCAP01_REG13
#define PCAP01_REG1
#define PCAP01_PU_RESET
#define PCAP01_REG4_VALUE
#define PCAP01_REG14
#define PCAP01_REG2
#define PCAP01_REG19
#define PCAP01_REG6
#define PCAP01_REG14_VALUE
#define PCAP01_REG11_VALUE
#define PCAP01_REG15_VALUE
#define PCAP01_ADDR
#define PCAP01_REG17
#define PCAP01_REG9_VALUE
#define PCAP01_REG5
#define PCAP01_IDLE
#define PCAP01_REG11
#define PCAP01_START
#define PCAP01_REG18
void writePCAP01_firmware(void)
#define PCAP01_REG16_VALUE
#define PCAP01_REG4
#define PCAP01_REG5_VALUE
uint32_t status
#define PCAP01_REG20_VALUE
uint32_t R_ratio
#define PCAP01_REG10
#define PCAP01_REG3_VALUE
#define PCAP01_REG7_VALUE
#define PCAP01_REG1_VALUE
#define PCAP01_GET_TEMP
#define PCAP01_REG9
#define PCAP01_REG16
#define PCAP01_REG10_VALUE
#define PCAP01_REG2_VALUE
#define PCAP01_REG17_VALUE
#define PCAP01_REG19_VALUE
#define PCAP01_REG8
#define PCAP01_REG12
#define PCAP01_REG12_VALUE
#define PCAP01_GET_HUMID
#define PCAP01_REG0
#define PCAP01_REG15
#define PCAP01_REG7
#define PCAP01_REG0_VALUE
#define PCAP01_REG3
#define PCAP01_REG13_VALUE
#define PCAP01_REG20
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
arch independent LED (Light Emitting Diodes) API
uint16_t foo
Definition main_demo5.c:58
Architecture independent timing functions.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.