14 #include <avr/pgmspace.h>
21 uint32_t t32Mhz,t2Mhz;
34 OUT(PORT_t *port,
const uint8_t pin): _port(port),_pin(pin) {
39 void on() { _on = (_port->OUTSET = _pin); }
40 void off() { _on = !(_port->OUTCLR = _pin); }
41 void toggle() { _on ? off() : on(); }
42 bool isOn() {
return _on; }
59 IN(PORT_t *port,
const uint8_t pin,
bool gc =
true);
61 return _gc ? !(_port->IN & _pin) : (_port->IN & _pin);
74 #define nCS1(value) { \
75 if(value) PORTD.OUTCLR = PIN3_bm; else PORTD.OUTSET = PIN3_bm; \
80 #define nCS2(value) { \
81 if(value) PORTD.OUTCLR = PIN2_bm; else PORTD.OUTSET = PIN2_bm; \
93 virtual void onCharReceived(
const char ) = 0;
104 static const char * CLRSCR;
105 static const char * CRLF;
114 USART& operator << (
const char);
115 USART& operator << (
const char *);
116 USART& operator >> (
char &);
133 virtual uint32_t
size() = 0;
137 virtual void init() = 0;
138 virtual size_t read(
const uint32_t address,
void * buffer,
size_t size) =0;
139 virtual size_t write(
const uint32_t address,
const void * buffer,
size_t size) = 0;
143 virtual bool erase() = 0;
147 virtual uint16_t
id() = 0;
151 virtual bool eraseBlock(
const uint32_t address) = 0;
169 SPI &operator >> (uint8_t &);
170 SPI &operator << (
const uint8_t);
171 const uint8_t
get() {
176 SPI &read(
void *buffer,
size_t size) {
177 uint8_t *p = (uint8_t *)buffer;
178 for(
size_t i=0;i<size;i++)
182 SPI &write(
const void *buffer,
size_t size) {
183 uint8_t *p = (uint8_t *)buffer;
184 for(
size_t i=0;i<size;i++)
205 OUT *
led(
const uint8_t which);
219 return _button.isOn();
234 extern Board *System;
virtual void shutdown()=0
bool isButtonPressed()
Definition: board.h:218
virtual uint32_t size()=0
OUT * led(const uint8_t which)
void setHandler(USARTHandler *handler)
Definition: board.h:109
IN(PORT_t *port, const uint8_t pin, bool gc=true)
USART & speed(const uint32_t)
static const size_t BLOCK_SIZE
размер минимально стираемого блока
Definition: board.h:128
virtual bool eraseBlock(const uint32_t address)=0
void setHiPerfomance(bool is32)
const uint32_t getTicksCount()