2 Copyright (C) 2012 jaseg <s@jaseg.de>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 3 as published by the Free Software Foundation.
9 //XXX The SS pin *MUST* not be used as an input when using SPI. For details see the datasheet.
11 void ${init_function()} (void){
12 DDR${device["spi"]["port"]} |= (1<<${device["spi"]["mosi"]}) | (1<<${device["spi"]["sck"]}) | (1<<${device["spi"]["ss"]});
13 PORT${device["spi"]["port"]} &= ~(1<<${device["spi"]["mosi"]}) & ~(1<<${device["spi"]["sck"]});
14 SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR1);
19 uint8_t spi_transfer(uint8_t data){
21 while(!(SPSR & _BV(SPIF))){
22 //She waves and opens a door back onto the piazza where her robot cat -- the alien's nightmare intruder in the DMZ -- sleeps, chasing superintelligent dream mice through multidimensional realities.
27 void ${module_callback("spi_transfer", "B", "B")}(const comm_callback_descriptor* cb, void* argbuf_end){
28 spi_transfer(global_argbuf[0]);