-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigitalpotans.c
More file actions
70 lines (57 loc) · 1.21 KB
/
digitalpotans.c
File metadata and controls
70 lines (57 loc) · 1.21 KB
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
/* Author: Steve Gunn, Ivan Ling
* Licence: This work is licensed under the Creative Commons Attribution License.
* View this license at http://creativecommons.org/about/licenses/
*/
#include <util/delay.h>
#include "spi.h"
#define READ 0x11 //Hint: Page 45 of datasheet
#define WRITE 0x00
#define INC 0x04
#define DEC 0x08
#define POT0 0x00 //Hint: Volatile wiper 0
#define POT1 0x10 //Hint: Volatile wiper 1
void init_pot(void)
{
init_spi_master();
}
void decXpot(void)
{
spi_tx(POT0 | DEC); //0x08
/* TODO: Code to decrement first pot by 1 */
}
void incXpot(void)
{
spi_tx(POT0 | INC); //0x04
/* TODO: Code to increment first pot by 1 */
}
void decYpot(void)
{
spi_tx(POT1 | DEC); //0x18
/* TODO: Code to decrement second pot by 1 */
}
void incYpot(void)
{
spi_tx(POT1 | INC); //0x14
/* TODO: Code to increment second pot by 1 */
}
void setXpot(uint8_t x)
{
spi_tx(POT0 | WRITE); //0x00
spi_tx(x);
/* TODO: Code to set first pot to a value between 0 and 255 */
}
void setYpot(uint8_t y)
{
spi_tx(POT1 | WRITE); //0x10
spi_tx(y);
/* TODO: Code to set second pot to a value between 0 and 255 */
}
/*
int main()
{
init_pot();
setYpot(0);
setYpot(0);
return 0;
}
*/