
If there are zero data, we return false.23: Take the first byte of the data address (purple). 20: We check if there was any data on this line.Meaning, there should be 16 bytes of data found on this line. Note, 10 is not a decimal number, it's hexadecimal.

The "10" is how many bytes of data (blue) found on this line. This should be the ':' character, but remember our clear_special_char() should skip this and read the next two bytes '1' and '0' (green). The above code parses exactly one line of hex data from the file pointer. 26: We increment two ASCII characters read from the file pointer.18: We combine the string of nibbles into a byte.(I will cover the Ascii2Hex function below.)The above steps are repeated for nibble B. 11: We then convert the ASCII character into a true binary nibble.8: Get an ASCII character from the file pointer.9: Here we call the cleaer_special_char function to remove '\n' and '\r' found in the hex file.6: Declaring a 8-bit unsinged integer to hold the finished byte.The function takes three parameters: the file pointer, a uint8_t pointer for storing the complete byte, and the total_chars_read, which allows us to track how far we are into the file. We then combine nibble A and B into a single byte. To make the conversion we get a character, store it as a binary nibble A, get another character and store it as binary nibble B. When we open a file pointer to these ASCII characters, we can't just read the bytes, since they'd simply be an ASCII character representing the nibble read. One bit to understand about hex files is the data is actually stored as ASCII characters. The function then returns the number of data bytes found in the hex file. This function reads the hex file, parses it, extracting the data and placing them into the the uint8_t array based on the data's address found in the hexfile. 23: We pass hex_file_to_array a file pointer and pointer to an an array.We pass it the file we wish to open and it returns the opened file. We are setting up to only read the file in binary. 20: We pass the pointer to the data stream to the open_file function.

17: Here we create a pointer to a file data stream.I've set it arbitrarily, but it will need to be large enough for the amount of data to be extracted from the hex file. 11: Declare a unsigned array for the data.

