-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhvsp.h
60 lines (45 loc) · 1.23 KB
/
hvsp.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
#ifndef _HVSP_H_
#define _HVSP_H_
#include <util.h>
/* This will be used in OCRA value for clock generation
* Should be multiple of 2 and 2 * val < 256, data timer will have double the period
* This should be calculated offline
* For F_CPU = 16000000 -> with 8 prescaler -> 2000000 / value = X khz
* 16 seems to be too small, interrupt can't keep up
*/
#define PERIOD_CLOCK (28U)
#ifndef PERIOD_CLOCK
#error "NO PERIOD CLOCK"
#endif
/* Using those because of the timer output pin
* Mandatory to be these pins on atmega324a
*/
#define SDI_PORT PORTD
#define SDI_DDR DDRD
#define SDI_PIN PD7
#define SII_PORT PORTD
#define SII_DDR DDRD
#define SII_PIN PD6
#define SCI_PORT PORTB
#define SCI_DDR DDRB
#define SCI_PIN PB3
/* End of section */
#define SDO_PORT PORTB
#define SDO_DDR DDRB
#define SDO_PIN PB1
/* Power and HV reset ports */
#define HV_PORT PORTB
#define HV_DDR DDRB
#define HV_PIN PB4
#define VCC_PORT PORTB
#define VCC_DDR DDRB
#define VCC_PIN PB5
/* Init HVSP module */
PUBLIC void initHVSP(void);
/* Start the HVSP bootup sequence */
PUBLIC void enterHVSPMode(void);
/* Sending SDI and SII bytes to HVSP interface.
* Not interrupt safe, not thread safe
*/
PUBLIC uint8_t sendBytesHVSP(uint8_t sii, uint8_t sdi);
#endif