// bar_graph_simple.c // R. Traylor // 10.22.13 // demos SPI // Every half second, a new data led is lit on the bargraph display via SPI // in a climbing pattern. // Expected Connections: // Bargraph board LED board or mega128 // -------------- -------------------- // reglck PORTB bit 0 (SS_n) // srclk PORTB bit 1 (sclk) // sdin PORTB bit 2 (mosi) // oe_n ground (short to gnd2) // gnd2 ground // vdd2 vcc // sd_out no connect #include #include //*********************************************************************** // spi_init // Initalizes the SPI port on the mega128. Does not do any further // external device specific initalizations. Sets up SPI to be: // master mode, clock=clk/2, cycle half phase, low polarity, MSB first // interrupts disabled, poll SPIF bit in SPSR to check xmit completion //********************************************************************** void spi_init(void){ DDRB = 0x07; //Turn on SS, MOSI, SCLK SPCR = (1<