Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- ISR (SPI_STC_vect) {
- static uint16_t v = 0;
- uint8_t c = SPDR;
- // if bit 7 is set, then retrieve a value
- // from the adc and send its upper bits
- if (c & 128) {
- int ch = A0 + c;
- v = analogRead(ch);
- SPDR = v >> 8;
- }
- else {
- SPDR = v;
- }
- }
- void setup (void) {
- Serial.begin(115200);
- Serial.println(F("Init " __DATE__ " " __TIME__));
- pinMode(SCK, INPUT);
- pinMode(MOSI, INPUT);
- pinMode(MISO, OUTPUT);
- pinMode(SS, INPUT);
- // enable SPI slave mode
- SPCR |= _BV(SPE);
- // switch on interrupts
- SPCR |= _BV(SPIE);
- }
- void loop (void) {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement