wip sram driver
This commit is contained in:
parent
4c9558852a
commit
1c8e8805d8
32
drivers/sram.c
Normal file
32
drivers/sram.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include "sram.h"
|
||||
|
||||
// 23LCV512 64kB SPI SRAM
|
||||
|
||||
uint8_t sram_status() {
|
||||
uint8_t v;
|
||||
PORTB &= ~(1 << 2);
|
||||
spi_transfer(0x05);
|
||||
v = spi_transfer(0x00);
|
||||
PORTB |= (1 << 2);
|
||||
return v;
|
||||
}
|
||||
|
||||
uint8_t sram_read(uint16_t addr) {
|
||||
uint8_t v;
|
||||
PORTB &= ~(1 << 2);
|
||||
spi_transfer(0x03);
|
||||
spi_transfer(addr & 0xFF);
|
||||
spi_transfer(addr > 8);
|
||||
v = spi_transfer(0x00);
|
||||
PORTB |= (1 << 2);
|
||||
return v;
|
||||
}
|
||||
|
||||
void sram_write(uint16_t addr, uint8_t v) {
|
||||
PORTB &= ~(1 << 2);
|
||||
spi_transfer(0x02);
|
||||
spi_transfer(addr & 0xFF);
|
||||
spi_transfer(addr > 8);
|
||||
spi_transfer(v);
|
||||
PORTB |= (1 << 2);
|
||||
}
|
6
drivers/sram.h
Normal file
6
drivers/sram.h
Normal file
@ -0,0 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
uint8_t sram_status();
|
||||
uint8_t sram_read(uint16_t addr);
|
||||
void sram_write(uint16_t addr, uint8_t v);
|
Loading…
Reference in New Issue
Block a user