42 MemRWCtrl.MemoryRW_State = API006_STATE_IDLE;
44 MemRWCtrl.MemoryRW_NumTotalBytesRequested = 0;
46 memset(&
MemRWCtrl.MemoryRW_LastPackageSend, 0,
sizeof(
MemRWCtrl.MemoryRW_LastPackageSend));
68 case API006_STATE_IDLE: ;
71 volatile uint8_t RW_bit_indicator = 0;
75 MemRWCtrl.MemoryRW_NumTotalBytesRequested = 0;
77 memset(&
MemRWCtrl.MemoryRW_LastPackageSend, 0,
sizeof(
MemRWCtrl.MemoryRW_LastPackageSend));
79 IntegrationCalibration__ClearWriteBuffer();
82 RW_bit_indicator = ((message->data[0] & 0x80) >> 7);
85 message->data[0] &= 0x7F;
88 for(
int i = 0; i < 4; i++)
89 MemRWCtrl.MemoryRW_AddressToRW += message->data[i] << (3 - i) * 8;
92 for(
int i = 0; i < 2; i++)
94 MemRWCtrl.MemoryRW_NumTotalBytesRequested += message->data[i + 4] << (1 - i) * 8;
108 MemRWCtrl.MemoryRW_State = API006_STATE_WRITE_REQUEST;
112 MemRWCtrl.MemoryRW_State = API006_STATE_READ_REQUEST;
118 case API006_STATE_READ_REQUEST: ;
120 volatile uint16_t Num_R_byte_sequence = 0;
121 volatile uint16_t Num_R_bytes_requested = 0;
124 for(
int i = 0; i < 2; i++)
126 Num_R_byte_sequence += message->data[i] << (1 - i) * 8;
127 Num_R_bytes_requested += message->data[i + 2] << (1 - i) * 8;
130 if((Num_R_byte_sequence + Num_R_bytes_requested <=
MemRWCtrl.MemoryRW_NumTotalBytesRequested)
134 for(
int i = 0; i < 2; i++)
135 MemRWCtrl.MemoryRW_LastPackageSend[i] = message->data[i];
138 for(
int i = 0;i < Num_R_bytes_requested;i++)
139 memcpy((
MemRWCtrl.MemoryRW_LastPackageSend + i + 2), ((uint8_t *)
MemRWCtrl.MemoryRW_AddressToRW + Num_R_byte_sequence + Num_R_bytes_requested - (1 + i)),
sizeof(uint8_t));
144 Tsp__LoadData(message->f_adress, Num_R_bytes_requested + 2,
MEMORYRW_API,
MemRWCtrl.MemoryRW_LastPackageSend);
148 if(Num_R_byte_sequence + (Num_R_bytes_requested) ==
MemRWCtrl.MemoryRW_NumTotalBytesRequested)
149 MemRWCtrl.MemoryRW_State = API006_STATE_IDLE;
153 MemRWCtrl.MemoryRW_State = API006_STATE_IDLE;
156 case API006_STATE_WRITE_REQUEST: ;
158 volatile uint16_t Num_W_byte_sequence = 0;
159 volatile uint16_t Num_W_bytes_requested = message->size - 6;
162 for(
int i = 0; i < 2; i++)
163 Num_W_byte_sequence += message->data[i] << (1 - i) * 8;
166 if(Num_W_byte_sequence + (Num_W_bytes_requested) <=
MemRWCtrl.MemoryRW_NumTotalBytesRequested)
168 IntegrationCalibration__InsertDataInBuffer(&message->data[2], Num_W_bytes_requested, Num_W_byte_sequence);
174 if(Num_W_byte_sequence + (Num_W_bytes_requested) ==
MemRWCtrl.MemoryRW_NumTotalBytesRequested)
177 if(
MemRWCtrl.MemoryRW_NumTotalBytesRequested > 0)
180 if(!(IntegrationCalibration__RequestFlashOperation(INTCALIB_FLASH_OPERATION_WRITE,
MemRWCtrl.MemoryRW_AddressToRW,
MemRWCtrl.MemoryRW_NumTotalBytesRequested)))
210 MemRWCtrl.MemoryRW_State = API006_STATE_IDLE;
215 MemRWCtrl.MemoryRW_State = API006_STATE_IDLE;
240 MemRWCtrl.MemoryRW_State = API006_STATE_IDLE;
void API006MemoryRW__Initialize(void)
It Initializes the module API006MemoryRW and its variables.
void API006MemoryRW__ResetState(void)
Reset the state of API for Idle.
API006_MEMORYRW_CONTROL_TYPE MemRWCtrl
API006_STATE_TYPE API006MemoryRW__GetState(void)
Get actual state of the API.
void API006MemoryRW__ReceiveParser(TSP_TYPE *message)
This function Parse the data receive for API006 and change the state of the API, if needed.
Header file for API006MemoryRW.c.
API006_STATE_TYPE
States possibles in operation.
#define MEMORYRW_API
API of Library.
#define MEMORYRW_ADRESS_LOWER_LIMIT
Address limit to make operations.
#define MEMORYRW_MAX_BYTES_READ_PACKAGE
Number max of bytes in a read package (data only)
#define MEMORYRW_MAX_BYTES_REQUESTED
Number max of bytes possible requested to read or write in one operation.
BOOL_TYPE Tsp__Send(BOOL_TYPE wait_ack)
Method to send Tsp message.
Struct for control parameters.