You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			98 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
			
		
		
	
	
			98 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
| /*
 | |
|  * ROM.h
 | |
|  *
 | |
|  *      Author: Aleksey Gerasimenko
 | |
|  *      gerasimenko.aleksey.n@gmail.com
 | |
|  */
 | |
| 
 | |
| #include <math.h>
 | |
| #include <stdint.h>
 | |
| 
 | |
| #include "framework.h"
 | |
| 
 | |
| #ifndef FRAM_ROM_H_
 | |
| #define FRAM_ROM_H_
 | |
| 
 | |
| namespace FRAM
 | |
| {
 | |
| 
 | |
| 
 | |
| struct ROMHeader
 | |
| {
 | |
|     uint16_t class_id;
 | |
|     uint16_t part_id;
 | |
|     uint16_t software_version;
 | |
|     uint16_t rom_size;
 | |
|     ROMHeader():
 | |
|         class_id(0),
 | |
|         part_id(0),
 | |
|         software_version(0),
 | |
|         rom_size(0)
 | |
|         {}
 | |
| };//ROMHeader
 | |
| 
 | |
| struct ROMFooter
 | |
| {
 | |
|     uint16_t magic;
 | |
|     ROMFooter():
 | |
|         magic(0)
 | |
|     {}
 | |
| };//ROMFooter
 | |
| 
 | |
| struct ROMSetup
 | |
| {
 | |
|     ROMHeader header;
 | |
|     ROMFooter footer;
 | |
|     ROMSetup():
 | |
|         header(),
 | |
|         footer()
 | |
|     {}
 | |
| };//ROMSetup
 | |
| 
 | |
| class ROM
 | |
| {
 | |
| public:
 | |
|     enum mode_t {UNDEFINED, OPERATIONAL};
 | |
| private:
 | |
|     mode_t m_mode;
 | |
| private:
 | |
|     ROMHeader m_header;
 | |
|     ROMFooter m_footer;
 | |
|     uint16_t m_int_last_address;
 | |
|     uint16_t m_flt_last_address;
 | |
| public:
 | |
|     ROM();
 | |
|     void setup(const ROMSetup setup);
 | |
| public:
 | |
|     mode_t get_mode();
 | |
|     bool compare(mode_t mode);
 | |
| public:
 | |
|     void write_float(float data, int16_t addr);
 | |
|     float read_float(int16_t addr);
 | |
|     void write_int(int16_t data, int16_t addr);
 | |
|     int16_t read_int(int16_t addr);
 | |
| private:
 | |
|     void (ROM::*_write_float)(float data, int16_t addr);
 | |
|     void _write_float_undef(float data, int16_t addr);
 | |
|     void _write_float_operate(float data, int16_t addr);
 | |
| private:
 | |
|     float (ROM::*_read_float)(int16_t addr);
 | |
|     float _read_float_undef(int16_t addr);
 | |
|     float _read_float_operate(int16_t addr);
 | |
| private:
 | |
|     void (ROM::*_write_int)(int16_t data, int16_t addr);
 | |
|     void _write_int_undef(int16_t data, int16_t addr);
 | |
|     void _write_int_operate(int16_t data, int16_t addr);
 | |
| private:
 | |
|     int16_t (ROM::*_read_int)(int16_t addr);
 | |
|     int16_t _read_int_undef(int16_t addr);
 | |
|     int16_t _read_int_operate(int16_t addr);
 | |
| 
 | |
| 
 | |
|     //
 | |
| };// class ROM
 | |
| 
 | |
| } /* namespace FRAM */
 | |
| 
 | |
| #endif /* FRAM_ROM_H_ */
 |