static int flashdisk_erase( const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment ) { int eno = 0; uint8_t *data = get_data_pointer(sd, segment, 0); memset(data, 0xff, sd->size); return eno; }
SenCmp02::SenCmp02(unsigned short _dev_id, unsigned short _comp_id, std::string _port, int _update_rate, int _debug, int _timings, std::list< std::pair<int, int> > _chanmap_pairs ) throw(const char *) : version(254), chanmap(CMP02_NUMCHAN) { //FIXME Initialisierung dev_id = _dev_id; comp_id = _comp_id; update_rate = _update_rate; debug = _debug; timings = _timings; Logger::log("Cmp02: init...", timings, Logger::LOGLEVEL_INFO); // channel mapping list<pair<int, int> >::const_iterator iter; iter = _chanmap_pairs.begin(); for(int i = 0; i < CMP02_NUMCHAN; i++) { // FIXME: rather two concurrent iterators? chanmap[i] = iter->second; Logger::log("Cmp02: chantype", chanmap[i], Logger::LOGLEVEL_DEBUG); iter++; } status = RUNNING; try { /* check config */ if (get_data_pointer(comp_id << 16) == NULL) { throw "sensor doesn't support configured function"; } fd = i2c_init(_port); status = STOPPED; } catch(const char *message) { status = UNINITIALIZED; string s(message); throw ("Cmp02(): " + s).c_str(); } }
static int flashdisk_write( const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment, uint32_t offset, const void *buffer, uint32_t size ) { int eno = 0; uint8_t *data = get_data_pointer(sd, segment, offset); memcpy(data, buffer, size); return eno; }
static int flashdisk_verify( const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment, uint32_t offset, const void *buffer, uint32_t size ) { int eno = 0; uint8_t *data = get_data_pointer(sd, segment, offset); if (memcmp(data, buffer, size) != 0) { eno = EIO; } return eno; }
static int flashdisk_blank( const rtems_fdisk_segment_desc *sd, uint32_t device, uint32_t segment, uint32_t offset, uint32_t size ) { int eno = 0; const uint8_t *current = get_data_pointer(sd, segment, offset); const uint8_t *end = current + size; while (eno == 0 && current != end) { if (*current != 0xff) { eno = EIO; } ++current; } return eno; }