@@ -49,9 +49,9 @@ class AVRprog:
49
49
50
50
def init (self , spi_bus , rst_pin ):
51
51
"""
52
- Initialize the programmer with SPI pins that will be used to
53
- communicate with the chip. Currently only hardware- SPI pins are
54
- supported!
52
+ Initialize the programmer with an SPI port that will be used to
53
+ communicate with the chip. Make sure your SPI supports 'write_readinto'
54
+ Also pass in a reset pin that will be used to get into programming mode
55
55
"""
56
56
self ._spi = spi_bus
57
57
self ._rst = DigitalInOut (rst_pin )
@@ -323,13 +323,19 @@ def _busy_wait(self):
323
323
324
324
def read_hex_page (file_state , page_addr , page_size , page_buffer ):
325
325
"""
326
- Helper function that does the Intel Hex parsing. Given an open file
327
- 'hexfile' and our desired buffer address start (page_addr), size
328
- (page_size) and an allocated bytearray. This function will try to
329
- read the file and fill the page_buffer. If the next line has data
330
- that is beyond the size of the page_address, it will return without
331
- changing the buffer, so pre-fill it with 0xFF (for sparsely-defined
332
- HEX files.
326
+ Helper function that does the Intel Hex parsing. Takes in a dictionary
327
+ that contains the file 'state'. The dictionary should have file_state['f']
328
+ be the file stream object (returned by open), the file_state['line'] which
329
+ tracks the line number of the file for better debug messages. This function
330
+ will update 'line' as it reads lines. It will set 'eof' when the file has
331
+ completed reading. It will also store the 'extended address' state in
332
+ file_state['ext_addr']
333
+ In addition to the file, it takes the desired buffer address start
334
+ (page_addr), size (page_size) and an allocated bytearray.
335
+ This function will try to read the file and fill the page_buffer.
336
+ If the next line has data that is beyond the size of the page_address,
337
+ it will return without changing the buffer, so pre-fill it with 0xFF
338
+ before calling, for sparsely-defined HEX files.
333
339
Returns False if the file has no more data to read. Returns True if
334
340
we've done the best job we can with filling the buffer and the next
335
341
line does not contain any more data we can use.
0 commit comments