forked from nonolith/cee-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cee.h
63 lines (52 loc) · 1.25 KB
/
cee.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#define F_CPU 32000000UL
// includes
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "Descriptors.h"
#include "usb.h"
// generic defines
typedef enum chan_mode{
DISABLED = 0,
SVMI = 1,
SIMV = 2,
CALIBRATE = 3,
} chan_mode;
#define A 0
#define B 1
#define FLAG_PACKET_DROPPED (1<<0)
void configChannelA(chan_mode state);
void configChannelB(chan_mode state);
// type definitions
typedef struct IN_sample{
uint8_t avl, ail, aih_avh, bvl, bil, bih_bvh;
} IN_sample;
typedef struct IN_packet{
uint8_t mode_a;
uint8_t mode_b;
uint8_t flags;
uint8_t mode_seq;
IN_sample data[10];
} __attribute__((packed)) IN_packet;
typedef struct OUT_sample{
uint8_t al, bl, bh_ah;
} __attribute__((packed)) OUT_sample;
typedef struct OUT_packet{
uint8_t mode_a;
uint8_t mode_b;
OUT_sample data[10];
} __attribute__((packed)) OUT_packet;
// function prototypes
void configHardware(void);
void initDAC(void);
void writeDAC(uint8_t flags, uint16_t value);
void initADC(void);
void configChannels(void);
void writeChannelA(uint8_t state);
void writeChannelB(uint8_t state);
void readADC(IN_sample* s);
bool EVENT_USB_Device_ControlRequest(USB_Request_Header_t* req);
void configISET(void);