Yanni Coroneos
/
mbed_4396_test
bleh
main.cpp@0:256c7510d40e, 2015-11-15 (annotated)
- Committer:
- sandwich
- Date:
- Sun Nov 15 00:51:39 2015 +0000
- Revision:
- 0:256c7510d40e
for debugging ak4396 fsm controller
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandwich | 0:256c7510d40e | 1 | #include "mbed.h" |
sandwich | 0:256c7510d40e | 2 | SPI spi(p5, p6, p7); // mosi, miso, sclk |
sandwich | 0:256c7510d40e | 3 | DigitalOut cs(p8); |
sandwich | 0:256c7510d40e | 4 | DigitalOut pdn(p9); |
sandwich | 0:256c7510d40e | 5 | DigitalOut myled(LED1); |
sandwich | 0:256c7510d40e | 6 | uint16_t control_2=0b0010000110011010; |
sandwich | 0:256c7510d40e | 7 | uint16_t control_1_rst=0b0010000010001110; |
sandwich | 0:256c7510d40e | 8 | uint16_t control_1_running=0b0010000010001111; |
sandwich | 0:256c7510d40e | 9 | int main() { |
sandwich | 0:256c7510d40e | 10 | // Chip must be deselected |
sandwich | 0:256c7510d40e | 11 | cs = 1; |
sandwich | 0:256c7510d40e | 12 | pdn=0; //power down |
sandwich | 0:256c7510d40e | 13 | wait_ms(1); |
sandwich | 0:256c7510d40e | 14 | pdn=1; |
sandwich | 0:256c7510d40e | 15 | wait_ms(1); |
sandwich | 0:256c7510d40e | 16 | |
sandwich | 0:256c7510d40e | 17 | // Setup the spi for 16 bit data, high steady state clock, |
sandwich | 0:256c7510d40e | 18 | // second edge capture, with a 1MHz clock rate |
sandwich | 0:256c7510d40e | 19 | spi.format(16,3); |
sandwich | 0:256c7510d40e | 20 | spi.frequency(9600); |
sandwich | 0:256c7510d40e | 21 | //while (1) |
sandwich | 0:256c7510d40e | 22 | // { |
sandwich | 0:256c7510d40e | 23 | // Select the device by seting chip select low |
sandwich | 0:256c7510d40e | 24 | cs = 0; |
sandwich | 0:256c7510d40e | 25 | // turn on zero_detect |
sandwich | 0:256c7510d40e | 26 | spi.write(control_2); |
sandwich | 0:256c7510d40e | 27 | // Deselect the device |
sandwich | 0:256c7510d40e | 28 | cs = 1; |
sandwich | 0:256c7510d40e | 29 | wait_ms(1); |
sandwich | 0:256c7510d40e | 30 | |
sandwich | 0:256c7510d40e | 31 | cs=0; |
sandwich | 0:256c7510d40e | 32 | spi.write(control_1_rst); |
sandwich | 0:256c7510d40e | 33 | cs=1; |
sandwich | 0:256c7510d40e | 34 | wait_ms(1); |
sandwich | 0:256c7510d40e | 35 | |
sandwich | 0:256c7510d40e | 36 | cs=0; |
sandwich | 0:256c7510d40e | 37 | spi.write(control_1_running); |
sandwich | 0:256c7510d40e | 38 | cs=1; |
sandwich | 0:256c7510d40e | 39 | wait_ms(1); |
sandwich | 0:256c7510d40e | 40 | //} |
sandwich | 0:256c7510d40e | 41 | while(1) { |
sandwich | 0:256c7510d40e | 42 | myled = 1; |
sandwich | 0:256c7510d40e | 43 | wait(0.2); |
sandwich | 0:256c7510d40e | 44 | myled = 0; |
sandwich | 0:256c7510d40e | 45 | wait(0.2); |
sandwich | 0:256c7510d40e | 46 | } |
sandwich | 0:256c7510d40e | 47 | } |