This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rock_status.c
62 lines (54 loc) · 1.84 KB
/
rock_status.c
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
#ifndef _rock_headers_h
#include "rock_headers.h"
#endif
void testTeamLEDPins()
{
// Set up Team LEDs on MAX7219
sendSPI(0x0200 + 0x04); m_wait(TEST_TEAM_LED_TIME_MS);
sendSPI(0x0200 + 0x08); m_wait(TEST_TEAM_LED_TIME_MS);
sendSPI(0x0200 + 0x00);
//m_set(RED_LED); m_wait(TEST_TEAM_LED_TIME_MS);
//m_set(BLUE_LED); m_wait(TEST_TEAM_LED_TIME_MS);
}
void testStatusLEDPins()
{
sendSPI(0x0100 + 0x01); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x03); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x06); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x0C); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x18); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x30); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x60); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0xC0); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x80);
sendSPI(0x0200 + 0x01); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0100 + 0x00);
sendSPI(0x0200 + 0x03); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0200 + 0x02); m_wait(TEST_STATUS_LED_TIME_MS);
sendSPI(0x0200 + 0x00);
}
void updateStatusFlags()
{
// SPI communication using the MAX7219 IC
sendSPI(0x0100 + LOW(statusFlags));
sendSPI(0x0200 + HIGH(statusFlags));
// MAX7219_DIN
// MAX7219_CLK
// MAX7219_LOAD
// Connect anodes to SEG lines
// Connect cathodes to DIG lines 0 and 1
// RED LED connects to same anode as LED bar array segment 3
// BLUE LED connects to same anode as LED bar array segment 4
// Take datasheet of LED array: DC fwd curr & fwd volt
// RSet will depend on these values (use table from MAX7219 datasheet)
// Typical value may be 33kOhm between Vcc and pin 18 (ISet)
}
void sendSPI(uint16_t data)
{
m_clear(SS);
SPDR = HIGH(data);
while(!check(SPSR,SPIF));
SPDR = LOW(data);
while(!check(SPSR,SPIF));
m_set(SS);
}