-
Notifications
You must be signed in to change notification settings - Fork 0
/
eSwitch.h
82 lines (65 loc) · 1.52 KB
/
eSwitch.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2017 NXP
// Arduino eSwitch driver
#include <SPI.h>
#include <TimerOne.h>
#include <stdint.h>
#ifndef eSwitch_H
#define eSwitch_H
#endif
#define CLK 6
#define RSTB 9
#define SPI_CSB 10
#define SPI_MOSI 11
#define SPI_MISO 12
#define SPI_CLK 13
#define CSNS A0
#define CSNS_Sync 0
#define Init1 0
#define Init2 1
#define CH1_Ctrl 2
#define CH2_Ctrl 3
#define CH3_Ctrl 4
#define CH4_Ctrl 5
#define CH5_Ctrl 6
#define CH6_Ctrl 7
#define OUT_Ctrl 8
#define GPWM1 9
#define GPWM2 10
#define OC_Ctrl1 11
#define OC_Ctrl2 12
#define Input_EN 13
#define PRS_Settings1 14
#define PRS_Settings2 15
#define OL_Ctrl 16
#define OLLED_Ctrl 17
#define Incr_Decr 1
void SendCmd(unsigned int cmd);
void InterruptTimer1(void);
// Init the SPI communication
void Init(void);
/*
This function is used to send
a SPI command to the eSwitch
*/
void WriteRegister(byte address, unsigned int data);
/*
This function allows to change the output register
of the product (1..9)
*/
void SetOutputRegister(unsigned int reg);
/*
This function is used to read
a SPI command to the eSwitch
*/
unsigned int ReadRegister(byte address);
void SetOutputState(byte channel, boolean state);
void SetPWMDuty(byte channel, byte value);
/*this function is used to set the monit*/
void SetMonitoring(byte mux);
/*This function returns the output current value*/
float GetOutputCurrent();
/*This function returns the power supply voltage*/
float GetVPWR();
/*This function returns the die temperature*/
float GetTemperature();
void setPwmFrequency(int pin, int divisor);