Skip to content

Commit 4896658

Browse files
- initial checkin
1 parent ebcca9c commit 4896658

43 files changed

Lines changed: 10698 additions & 23 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Version Changelog
2+
1.0 first released version

LICENSE

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
MIT License
2-
3-
Copyright (c) 2025 ams OSRAM
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
Copyright (C) 2025 AMS-OSRAM
2+
3+
The MIT License (MIT)
4+
Copyright © 2025 <copyright holders>
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
7+
and associated documentation files (the “Software”), to deal in the Software without
8+
restriction, including without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
10+
Software is furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or
13+
substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
16+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,102 @@
1-
# tmf8829_driver_python
2-
TMF8829 Python driver
1+
# Python files for the tmf8829 device
2+
3+
Python version 3.10.11 or high is required.
4+
5+
## Virtual environment
6+
7+
Recommendation is to set-up a virtual environment. Open you favorite Windows PowerShell, VisualStudio Code etc.
8+
To install a virtual environment named env, and use it:
9+
python -m venv env
10+
./env/Scripts/Activate.ps1
11+
12+
## Requirements
13+
14+
To run the scripts in this folder you need to install the packages in the requirements.txt file with:
15+
pip install -r requirements.txt
16+
17+
All needed python packages are located in the subdirectory packages.
18+
19+
## Folder and sub-folders:
20+
21+
### ./packages
22+
Needed python packages.
23+
24+
25+
### ./tmf8829
26+
All python classes, files and functions, specific to the TMF8829.
27+
28+
##### tmf8829_application.py, tmf8829_application_common.py and tmf8829_bootloader.py:
29+
The application and bootloader classes have the functionality to control the device hardware and the bootloader and also allows to download intel hex files to the device, measurements and the reading of result and histogram frames.
30+
31+
##### tmf8829_application defines.py:
32+
Application specific defines and structures.
33+
34+
##### tmf8829_conv.py:
35+
Contains convenience functions.
36+
37+
#### Python register files
38+
39+
##### tmf8829_host_regs.py
40+
The registers of the Tmf8829 which could be written over I2C or SPI.
41+
42+
##### tmf8829_application_registers.py:
43+
Application specific registers.
44+
45+
##### tmf8829_config_page.py:
46+
Application configuration register page.
47+
48+
### ./tmf8829/examples
49+
Several examples that show the usage of how to:
50+
- use the application printer to see results/frames in the terminal
51+
- visualize pixel results or histograms
52+
- log data into a file with json format.
53+
54+
### ./tmf8829/utilities
55+
56+
##### tmf8829_application_printer.py:
57+
The application printer class supports the printing of the results and histogram frames.
58+
59+
##### tmf8829_json_2_csv.py
60+
Convert log files from json format to csv format
61+
62+
##### tmf8829_logger_service.py
63+
Provides functionality to dump the data into a file with json format or to log data into a textfile.
64+
65+
66+
##### tmf8829_visualisation.py
67+
Functionality to visualize pixel data or histograms.
68+
69+
### ./tmf8829/zeromq
70+
71+
zeroMQ is an open source universal messaging library.
72+
zeroMq server implementations for the tmf8829 EVMs are available and for host interaction a zeroMq client.
73+
74+
##### TMF8829_zeromq_protocol.md
75+
The protocol description.
76+
77+
##### tmf8829_host_com_reg.py
78+
The definition of the protocol header.
79+
80+
##### tmf8829_zeromq_common.py
81+
Common functions for the client and server.
82+
83+
##### tmf8829_zeromq_client.py
84+
Client that could be used as active or passive logger
85+
86+
##### tmf8829_zeromq_server_core.py
87+
Common functions for the different server scripts.
88+
89+
##### tmf8829_zeromq_server.py
90+
Server for the EVM shield board.
91+
92+
##### tmf8829_zeromq_server_linux.py
93+
Server for the evm linux board.
94+
95+
##### tmf8829_zeromq_server_arduino.py
96+
Server for the Arduino board.
97+
98+
##### cfg_client.json
99+
TMF8829 configuration for active logging and general logging parameters.
100+
101+
##### cfg_server.json
102+
TMF8829 configuration at startup of the server.
191 KB
Binary file not shown.
155 KB
Binary file not shown.

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
packages\aos_com-1.0.19-py3-none-any.whl
2+
packages\corefw_c-2.2.1-cp38-abi3-win_amd64.whl
3+
pyserial
4+
intelhex
5+
matplotlib
6+
numpy
7+
pyzmq==25.1.2
8+
pyinstaller

tmf8829/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Version Changelog
2+
1.0 first released version

tmf8829/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# *****************************************************************************
2+
# * Copyright by ams OSRAM AG *
3+
# * All rights are reserved. *
4+
# * *
5+
# *FOR FULL LICENSE TEXT SEE LICENSES-MIT.TXT *
6+
# *****************************************************************************
7+
8+
9+
""" Import this script to set up the python path.
10+
"""
11+
12+
import os
13+
import sys
14+
15+
TOF_PYTHON_ROOT_DIR = os.path.normpath(os.path.dirname(__file__))
16+
"""Change this path depending on the relative path between this file and the TOF python root dir."""
17+
18+
if TOF_PYTHON_ROOT_DIR not in sys.path:
19+
sys.path.append(TOF_PYTHON_ROOT_DIR)
20+

tmf8829/aos_com/register_io.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# *****************************************************************************
2+
# * Copyright by ams OSRAM AG *
3+
# * All rights are reserved. *
4+
# * *
5+
# *FOR FULL LICENSE TEXT SEE LICENSES-MIT.TXT *
6+
# *****************************************************************************
7+
"""
8+
This class allows to read and write registers or register+block
9+
"""
10+
11+
import ctypes
12+
13+
14+
class RegisterIo:
15+
"""Class that handles register read, register write, and register print.
16+
Uses IcCom for communication."""
17+
18+
LOG_NONE = 0
19+
LOG_INFO = 1 # only print register info, no fifo, no block read
20+
LOG_VERBOSE = 10
21+
22+
def __init__(self,ic_com,dev_addr:int=-1,log_level:int=LOG_INFO,i2c_print:bool=False,addr_width_in_bytes:int=1):
23+
pass
24+
25+
26+
def ctypes2Dict(frame):
27+
"""To convert a simple ctypes frame into a dictionary call this function. this is a recursive function.
28+
Args:
29+
frame: a ctpye structure/list
30+
"""
31+
# if the type is not a primitive and it evaluates to False ...
32+
if (type(frame) not in [int, float, bool]) and not bool(frame):
33+
# it's a null pointer
34+
return 0
35+
elif (type(frame) in [int, float, bool]):
36+
return frame
37+
elif hasattr(frame, "_length_") and hasattr(frame, "_type_"):
38+
# Probably an array
39+
return list(map(ctypes2Dict, frame))
40+
elif hasattr(frame, "_fields_"):
41+
result = {}
42+
for temp in frame._fields_:
43+
field = temp[0]
44+
v = getattr(frame, field)
45+
result[field] = ctypes2Dict(v)
46+
return result
47+
return None
48+
49+
def dict2Ctypes(struct_type, values):
50+
"""Convert a dictionary back to a ctypes Structure/Array.
51+
52+
Args:
53+
struct_type (class): The data type to be filled. Must be of base class ctypes.Structure|ctypes.Array.
54+
values (dict|array): The dictionary or array which was previously generated by ctypes2Dict().
55+
Returns:
56+
struct_type: A ctypes instance with the data from the dictionary.
57+
58+
Example::
59+
60+
class DummyStructure(ctypes.LittleEndianStructure):
61+
_pack_ = 1
62+
_fields_ = [
63+
("bitfield1", ctypes.c_uint8, 1),
64+
("bitfield2", ctypes.c_uint8, 7),
65+
("array", ctypes.c_uint8*6),
66+
]
67+
data = DummyStructure()
68+
data.bitfield1 = 1
69+
data.bitfield2 = 23
70+
data.array = (ctypes.c_uint8*6)(*range(6))
71+
print([hex(x) for x in bytes(data)])
72+
data_dict = ctypes2Dict(data)
73+
print(data_dict)
74+
data_recovered = dict2Ctypes(DummyStructure, data_dict)
75+
print([hex(x) for x in bytes(data_recovered)])
76+
"""
77+
def _dict2Ctypes(dst, value):
78+
""" A helper function to pass the ctypes instance by reference. Is called recursively."""
79+
if type(value) is list:
80+
assert hasattr(dst, "_length_")
81+
for i, v in enumerate(value):
82+
if type(v) in [int, float, bool]:
83+
dst[i] = v
84+
else:
85+
_dict2Ctypes(dst[i], v)
86+
elif type(value) is dict:
87+
for field_name in value:
88+
v = value[field_name]
89+
if type(v) in [int, float, bool]:
90+
assert hasattr(dst, field_name)
91+
setattr(dst, field_name, v)
92+
else:
93+
_dict2Ctypes(getattr(dst, field_name), v)
94+
else:
95+
assert False, "Types other than lists or structs are not allowed."
96+
pass
97+
res = struct_type()
98+
_dict2Ctypes(res, values)
99+
return res
100+

tmf8829/examples/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# *****************************************************************************
2+
# * Copyright by ams OSRAM AG *
3+
# * All rights are reserved. *
4+
# * *
5+
# *FOR FULL LICENSE TEXT SEE LICENSES-MIT.TXT *
6+
# *****************************************************************************
7+
""" Import this script to set up the python path.
8+
"""
9+
10+
import os
11+
import sys
12+
13+
TOF_PYTHON_ROOT_DIR = os.path.normpath(os.path.dirname(__file__) + "/..")
14+
"""Change this path depending on the relative path between this file and the TOF python root dir."""
15+
16+
if TOF_PYTHON_ROOT_DIR not in sys.path:
17+
sys.path.append(TOF_PYTHON_ROOT_DIR)
18+
19+
HEX_FILE = os.path.dirname(__file__) + "\\..\\hex\\tmf8829_application.hex"

0 commit comments

Comments
 (0)