Statistics
| Branch: | Tag: | Revision:

amiro-os / include / amiro / eeprom / at24.hpp @ 5b1b6715

History | View | Annotate | Download (818 Bytes)

1
#ifndef AT24_HPP_
2
#define AT24_HPP_
3

    
4
#include <ch.hpp>
5
#include <hal.h>
6

    
7
#include <amiro/eeprom/eeprom.hpp>
8

    
9
namespace amiro {
10

    
11
class I2CDriver;
12

    
13
class AT24 : public EEPROM {
14

    
15
  enum {
16
    AT24_SLA = 0x50u,
17
  };
18

    
19
  enum {
20
    AT24_MAX_PAGE_SIZE = 8,
21
  };
22

    
23
  public:
24

    
25
  /**
26
    * Return types of getCheck()
27
    */
28
   enum {
29
     CHECK_OK          = 0x00u,
30
     CHECK_READ_FAIL   = 0x01u,
31
     CHECK_WRITE_FAIL  = 0x02u,
32
     CHECK_CHKSUM_FAIL = 0x03u,
33
   };
34

    
35
    AT24(size_t size, uint8_t page_size, uint16_t max_t_wr, I2CDriver* i2c_driver);
36
    ~AT24();
37

    
38
    static msg_t poll_ack(void* instance);
39
    static size_t write(void* instance, const uint8_t* bp, size_t n);
40
    static size_t read(void* instance, uint8_t* bp, size_t n);
41
    static uint32_t close(void* instance);
42

    
43
};
44

    
45
} /* amiro */
46

    
47
#endif /* AT24_HPP_ */