Allen Litton
/
BreakoutBoardDemo
Demo Application for the Celeritous Breakout Board
L25AA02EA48/L25AA02EA48.cpp@0:1a3da73fe36a, 2012-05-18 (annotated)
- Committer:
- celeritous
- Date:
- Fri May 18 03:55:10 2012 +0000
- Revision:
- 0:1a3da73fe36a
Celeritous_BreakoutBoardDemo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
celeritous | 0:1a3da73fe36a | 1 | #include "L25AA02EA48.h" |
celeritous | 0:1a3da73fe36a | 2 | L25AA02EA48::L25AA02EA48(PinName MOSI, PinName MISO, PinName SCLK, PinName CS) : _serial(MOSI,MISO,SCLK), _cs(CS) |
celeritous | 0:1a3da73fe36a | 3 | { |
celeritous | 0:1a3da73fe36a | 4 | _cs = 1; |
celeritous | 0:1a3da73fe36a | 5 | _serial.frequency(2000000); |
celeritous | 0:1a3da73fe36a | 6 | _serial.format(8,3); |
celeritous | 0:1a3da73fe36a | 7 | } |
celeritous | 0:1a3da73fe36a | 8 | |
celeritous | 0:1a3da73fe36a | 9 | int L25AA02EA48::command(int c) |
celeritous | 0:1a3da73fe36a | 10 | { |
celeritous | 0:1a3da73fe36a | 11 | int response=0; |
celeritous | 0:1a3da73fe36a | 12 | _cs = 0; |
celeritous | 0:1a3da73fe36a | 13 | |
celeritous | 0:1a3da73fe36a | 14 | _serial.write(c); |
celeritous | 0:1a3da73fe36a | 15 | response = _serial.write(0x0); //address 0 |
celeritous | 0:1a3da73fe36a | 16 | |
celeritous | 0:1a3da73fe36a | 17 | _cs = 1; |
celeritous | 0:1a3da73fe36a | 18 | return response; |
celeritous | 0:1a3da73fe36a | 19 | } |
celeritous | 0:1a3da73fe36a | 20 | |
celeritous | 0:1a3da73fe36a | 21 | int L25AA02EA48::read_address(int a) |
celeritous | 0:1a3da73fe36a | 22 | { |
celeritous | 0:1a3da73fe36a | 23 | int response=0; |
celeritous | 0:1a3da73fe36a | 24 | _cs = 0; |
celeritous | 0:1a3da73fe36a | 25 | |
celeritous | 0:1a3da73fe36a | 26 | _serial.write(COMMAND_READ); |
celeritous | 0:1a3da73fe36a | 27 | _serial.write(a); //address 0 |
celeritous | 0:1a3da73fe36a | 28 | response=_serial.write(0x0); |
celeritous | 0:1a3da73fe36a | 29 | _cs = 1; |
celeritous | 0:1a3da73fe36a | 30 | return response; |
celeritous | 0:1a3da73fe36a | 31 | } |
celeritous | 0:1a3da73fe36a | 32 | char * L25AA02EA48::getMacAddress() |
celeritous | 0:1a3da73fe36a | 33 | { |
celeritous | 0:1a3da73fe36a | 34 | // for (int i=0; i<6; i++) |
celeritous | 0:1a3da73fe36a | 35 | // MacAddress[i] = read_address(0xfa+i); |
celeritous | 0:1a3da73fe36a | 36 | |
celeritous | 0:1a3da73fe36a | 37 | _cs = 0; |
celeritous | 0:1a3da73fe36a | 38 | |
celeritous | 0:1a3da73fe36a | 39 | _serial.write(COMMAND_READ); |
celeritous | 0:1a3da73fe36a | 40 | _serial.write(0xfa); //address 0 |
celeritous | 0:1a3da73fe36a | 41 | for(int i=0; i<6; i++) |
celeritous | 0:1a3da73fe36a | 42 | MacAddress[i]=_serial.write(0x0); |
celeritous | 0:1a3da73fe36a | 43 | |
celeritous | 0:1a3da73fe36a | 44 | _cs = 1; |
celeritous | 0:1a3da73fe36a | 45 | return MacAddress; |
celeritous | 0:1a3da73fe36a | 46 | } |