Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "main.h"
- #include "delay.h"
- #include "AS1107_driver.h"
- //Strobe the CLOCK line
- void AS1107_clock() {
- CLOCK = 1;
- Nop();
- CLOCK = 0;
- Nop();
- }
- //Strobe the LATCH line
- void AS1107_latch() {
- LATCH = 1;
- Nop();
- LATCH = 0;
- Nop();
- }
- void AS1107_send_data(byte address, byte data) {
- byte c;
- //The first 4 bits are not used
- DATA = 0;
- AS1107_clock();
- AS1107_clock();
- AS1107_clock();
- AS1107_clock();
- //Clock in the next 4 bits (register address)
- for(c = 4; c > 0; c--) {
- DATA = (address >> c) & 1;
- AS1107_clock();
- }
- //Clock in the next 8 bits (register data)
- for(c = 8; c > 0; c--) {
- DATA = (data >> c) & 1;
- AS1107_clock();
- }
- //Latch in the data
- AS1107_latch();
- }
- void AS1107_init() {
- AS1107_latch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement