aboutsummaryrefslogtreecommitdiff
path: root/write_prog_eeprom.py
blob: 80fcc2d6b8360b41e273fc5603a01fe79671c661 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## This file write different programms to the EEPROM AT28C

## programm start at 0x00

import test_prog
import fibonacci


import eeprom_pi as ep
import sys

prog = None

if len(sys.argv) == 2:
	if sys.argv[1] == "test":
		prog = test_prog.prog
	elif sys.argv[1] == "fibonacci":
		prog = fibonacci.prog
	

if prog == None:
	print("error: please specify a valid programm.")
	print("valid programms are: test, fibonacci")
	exit()

## start at addres 0x0
address = 0x0
inst_nr = 0

ep.init_board()

for instruction in prog:
	print("%s: %s" % (hex(address+inst_nr), hex(instruction)))
	ep.write_data_at(address+inst_nr, instruction)
	inst_nr += 1

trash = raw_input("please unplug the power from the EEPORM and press any key to continue")

ep.cleanup()