text: /*
  * c_core_avr_2560.h
  *
  * Created: 2/27/2019 3:47:53 PM
  * Author: jeff_d
  */
  
  #ifndef __C_DISK_STM32H745_H__
  #define __C_DISK_STM32H745_H__
  
  #include <stdint.h>
  //#include "../../../../NGC_RS274/_ngc_block_struct.h"
  //#include "../../../../NGC_RS274/_ngc_tool_struct.h"
  //#include "../../../../NGC_RS274/_ngc_coordinate_struct.h"
  //#include "../../../../NGC_RS274/_ngc_parameter_class_enum.h"
  
  //#include "disk_support/SPI/Hardware/sd_card.h"
  #include "disk_support/SDMMC/Hardware/sd_card.h"
  #include "../_bit_flag_control.h"
  
  namespace Hardware_Abstraction_Layer
  {
  	class Disk
  	{
  	public:
  		class File_Ids
  		{
  		public:
  			enum class e_file_states
  			{
  				//first 15 (0-14) bits are used for error
  				hardware_error = 0,
  				end_of_file_reached = 1,
  			};
  
  			s_bit_flag_controller_8<e_file_states> states;
  			FIL file_object;
  			char * file_name;
  			uint32_t rec_begin;
  			uint32_t rec_size;
  		};
  		enum class e_file_modes
  		{
  			OpenCreate = 0,
  			Open = 1,
  			OverWrite = 2,
  			Append = 3
  		};
  
  		//variables
  	
  		enum class e_disk_states
  		{
  			//first 15 (0-14) bits are used for error
  			hardware_error = 0,
  			drive_start_error = 1,
  			drive_mount_error = 2,
  			cache_open_error = 3,
  			tool_open_error = 4,
  			wcs_open_error = 5,
  			mcs_open_error = 6,
  			motion_setting_open_error = 7,
  			default_block_open_error = 8,
  			interpreter_setting_open_error = 9,
  			name_parameter_open_error = 10,
  			number_parameter_open_error = 11,
  
  			//second 15 (15-31) bits are used for success
  			hardware_success = hardware_error + 15,
  			drive_start_success = drive_start_error + 15,
  			drive_mount_success = drive_mount_error + 15,
  			cache_open_success = cache_open_error + 15,
  			tool_open_success = tool_open_error + 15,
  			wcs_open_success = wcs_open_error + 15,
  			mcs_open_success = mcs_open_error + 15,
  			motion_setting_open_success = motion_setting_open_error + 15,
  			default_block_open_success = default_block_open_error + 15,
  			interpreter_setting_open_success = interpreter_setting_open_error + 15,
  			name_parameter_open_success = name_parameter_open_error +15,
  			number_parameter_open_success = number_parameter_open_error + 15,
  		};
  
  		static s_bit_flag_controller_32<uint32_t> states;
  
  		static File_Ids par_file[];
  		static File_Ids interp;
  		static File_Ids tool;
  		static File_Ids def_blk;
  		static File_Ids wcs_blk;
  		static File_Ids mcs_blk;
  		static File_Ids motion;
  		static File_Ids cache;
  		static File_Ids machine;
  	protected:
  	private:
  
  		//functions
  	public:
  
  		static uint8_t initialize(void(*string_writer)(int serial_id, const char* data));
  		static uint8_t load_configuration();
  
  		static uint8_t read_file(char* filename, char* buffer);
  
  		static uint8_t open_file(File_Ids * file, char* name, e_disk_states flag_success_byte, e_disk_states flag_fail_byte);
  
  		static uint8_t put(char* stream, uint16_t size, File_Ids* par_file, uint32_t record_num);
  		static uint8_t get(char* stream, uint16_t size, File_Ids * par_file, uint32_t record_num);
  		
  		static uint8_t write(File_Ids* file, char* buffer, e_file_modes mode, uint16_t size);
  		static uint8_t read(File_Ids* file, char* buffer, e_file_modes mode, uint16_t size);
  	protected:
  	private:
  
  
  	};
  };
  #endif