85 Commits

Author SHA1 Message Date
Nic Limper
ebd1adc0d5 gzipped www files 2024-02-28 01:20:37 +01:00
Nic Limper
f4cb642142 add Denmark to dayahead electricity prices; enable it also for 2.9" UC8151 2024-02-28 01:11:01 +01:00
Nic Limper
9b2d76a6b6 bugfix: idlereq should not be queued, and only sent when queue is empty 2024-02-28 01:09:00 +01:00
leXorNet
ac979a3c52 Added Swedish content language (#245) 2024-02-27 12:11:13 +01:00
Jan-Henrik Bruhn
a606c4c1aa Use relative paths for fetch calls and websocket (#243)
This allows the OEPL Frontend to be put behind a reverse proxy like Home
Assistant Ingress to proxy it behind a relative path.
2024-02-27 01:47:36 +01:00
Jelmer
c22fe0d91b Merge pull request #241 from TheRealMrSteel/patch-1
Update content_cards.json
2024-02-27 00:37:42 +01:00
Jelmer
b29907a725 Merge pull request #242 from VstudioLAB/M3_58-26-29FREEZER
M3 58 26 29 freezer
2024-02-27 00:36:03 +01:00
Jelmer
8da475901d Support for rotating generated images based on tagtype profile 2024-02-27 00:32:09 +01:00
Vstudio LAB
e4ed0b13db Delete ARM_Tag_FW/Newton_M3_nRF52811/$PROJECT_DIR directory 2024-02-26 22:55:48 +01:00
VstudioLAB
0ffd0fbf0e Update .gitignore 2024-02-26 22:49:03 +01:00
Steel
1cba70b9cc Update content_cards.json
typo in id19
2024-02-26 22:47:50 +01:00
VstudioLAB
6b67f6df2b updates 2024-02-26 22:24:48 +01:00
Nic Limper
b9fe72de5c small bugfixes 2024-02-26 20:58:46 +01:00
Nic Limper
c458c6b29c bugfix: config screen is not populated when alias is empty 2024-02-26 11:47:56 +01:00
jjwbruijn
d3b9abf56a M2 7.5" v0027 fw 2024-02-26 01:27:40 +01:00
Jelmer
d2b17b7a97 added M2 7.5" BW tag type 2024-02-25 23:10:40 +01:00
Nic Limper
7e3e73a064 bugfix: no flasher-only detection on tag-based AP 2024-02-25 21:39:28 +01:00
Jelmer
9ca9007a1c Update oepl-definitions.h 2024-02-25 19:57:20 +01:00
Nic Limper
b03ad07179 bugfix, AP always reported C6 present 2024-02-25 15:26:01 +01:00
Nic Limper
56537e46be dirty fix for zlib compression
The miniz is used for zlib compression. But because that library has some bugs related to a smal window sizes (we need 4096), I had to make some patches to the library. The miniz library happens to also be part of esp-idf. To distinguish between our version and the esp-idf version, I created a `namespace Miniz` around our version. But nevertheless, the esp-idf version is called when I'm calling Miniz::tdefl_init and Miniz::tdefl_compress . Why??
Anyway, renamed tdefl_init and tdefl_compress to tdefl_initOEPL and tdefl_compressOEPL to get it working. This is ugly. If somebody has a better solution, please let me know!
2024-02-25 14:45:03 +01:00
Nic Limper
bc06ea74e8 gzipped web files 2024-02-24 14:04:47 +01:00
Nic Limper
9137c5acb1 add BLE to all ESP32-S3 based AP's (default disabled; enable in the config screen if needed) 2024-02-24 14:01:27 +01:00
Nic Limper
c0e59dadb4 webflasher serial passthrough, work in progress, turned off for now 2024-02-24 12:46:27 +01:00
Nic Limper
0dd3a8459b fix for mini AP 2024-02-23 17:19:08 +01:00
Nic Limper
ebd6b5289c lot of small fixes
- adds tag serial debug in webflasher and power up/down buttons
- fixes bug where esp32-s3 connected via usb cdc slows down when no terminal connection is present
- fix: ghost tags reporting a different channel id than the AP are now ignored
- webflasher now ramps up/down power to prevent spikes
- bugfix: C6 doesn't get reset anoymore by the watchdog during flashing
- bugfix: C6 could go in flash mode unintended
- a failed connection during swd write blocks is now reported back instead of silently ignored
- added 4 areas of Sweden to day ahead price content
- new context menu option 'Delete all inactive tags' (only when right clicking on an inactive tag).
- adjusted some timings
2024-02-23 17:08:52 +01:00
atc1441
65558360ef Added offline lines to TLSR FW, If the AP is not found the display will draw 5 lines to notify the user 2024-02-20 18:12:44 +01:00
atc1441
dd69fa029a Added ATC_MiThermometer to the BLE part. This allows to receive the Advertising data from the Custom firmware running on the Thermometer via BLE 2024-02-16 18:12:13 +01:00
atc1441
9bbd30b783 Fixed TLSR No AP useless refresh 2024-02-16 16:04:49 +01:00
jjwbruijn
691b688f46 added magic numbers to M2 7.5" 2024-02-16 01:17:11 +01:00
Jelmer
3d125c415f mkfs.OEPL README.md 2024-02-15 23:36:35 +01:00
jjwbruijn
f2dc16953d beta v0027 M2-7.5" FW 2024-02-15 18:51:10 +01:00
jjwbruijn
f38e121c94 More OEPLFS stuff for 88MZ100 2024-02-15 18:34:22 +01:00
VstudioLAB
f83667bcce Added support for the 2.6 BWR 2024-02-15 13:25:58 +01:00
VstudioLAB
bee51a23b6 5.85" Initial support and general preparation for BW only compatibility. 2024-02-15 00:09:25 +01:00
VstudioLAB
a787ac6ddf M3 5.85" cleanning 2024-02-14 22:09:50 +01:00
VstudioLAB
5561f82bf6 Original commit (5.85" BWR only)
First commit of that branch.
At the moment, only the M3 5.85" is added, but not finished.
2024-02-14 21:39:36 +01:00
VstudioLAB
b07eeb31ce initial commit 2024-02-14 00:56:38 +01:00
jjwbruijn
57748d825b Added compression to M3, moved stuff around 2024-02-13 22:38:36 +01:00
Jelmer
d7f6fee31f Update oepl-definitions.h 2024-02-11 14:57:57 +01:00
Jelmer
1cb948e0b6 Update oepl-definitions.h 2024-02-11 14:57:20 +01:00
atc1441
aca1dfc7a3 Added Gicisky / PICKSMART BLE E-Paper Display support. Can be activated via the -D HAS_BLE_WRITER definition in the platformio.ini
This enables direct BLE Image upload from the Main ESP32 SoC via BLE and allows an OEPL usage without soldering/flashing or extra ZigBee interface.
Currently tested on the 2.9" BW and 4.2" BWR version, tagtypes need to be added for more versions

Demo video:
https://youtu.be/_efgMQUA1F4

Official description of the BLE Protocol here:
https://zhuanlan.zhihu.com/p/633113543

Thanks to these wonderful guys for such a good overview:
https://github.com/fpoli/gicisky-tag
https://github.com/Cabalist/gicisky_image_notes
2024-02-10 23:02:34 +01:00
Jelmer
edb874029e Merge pull request #226 from VstudioLAB/ST‐GM29MT1
Adding support to the ST‐GM29MT1 BW (UC8151)
2024-02-08 20:45:49 +01:00
VstudioLAB
a1eba95ce2 Create 27.json 2024-02-08 17:51:38 +01:00
VstudioLAB
4f1252d839 Original commit for this support 2024-02-08 17:36:48 +01:00
Nic Limper
b4836e81f3 tag flasher / timestamp content / bugfixes (#217)
- added webinterface for tag flasher
- added tcp transport for communicating with tag flasher (OTG USB also still works)
- added content 'timestamp', makes use of preloaded images and buttons on the 2.9" M3
- webinterface is now aware of C6 and flasher capabilities
- AP can run without ieee801.15.4 radio (i.e. flasher only) by shorting FLASHER_AP_TXD and FLASHER_AP_RXD
- added tcp transport option to OEPL-Flasher.py (serial also still works)
- added new environment OpenEPaperLink_Mini_AP_v4
- lots of finetuning and bug fixes
2024-02-04 20:30:52 +01:00
Nic Limper
472f148b0c typo 2024-02-02 16:36:27 +01:00
Nic Limper
107c85e3cf bugfix: too long pending filenames after a few hours of uptime 2024-02-02 16:22:19 +01:00
Nic Limper
1835b1cda7 gzipped wwwroot 2024-01-30 11:56:19 +01:00
Nic Limper
b71844eac0 imgupload performance / Norway dayahead codes 2024-01-30 11:23:58 +01:00
Nic Limper
72c1b7bf40 bugfix dayahead 2024-01-30 00:49:49 +01:00
Nic Limper
1c7d45865d new content type: day ahead prices (S3-based AP only) 2024-01-30 00:33:22 +01:00
Nic Limper
7fd04d1ae3 esp32 support for compressed images to tag 2024-01-29 02:50:39 +01:00
Nic Limper
6292e73135 Pending queue (#210)
Pretty complex change here: pending images/commands are now queued.

A command (like LED flasher) will not overwrite a pending image anymore. Also, sending multiple preloaded images is possible.
Also works (at least, as far as I could test) in combination with Multi AP and mirroring tags ('display a copy' content type).

It you want to test this: don't forget to upload the changed files in /www (the pending icon is now displaying the amount of queued messages). Timing improvements will follow later (only one message can be transmitted every checkin. If multiple messages are queued, at this moment, you have to wait until the next checkin which takes 40-60 sec).

This comes also with the advantage of better stability if you upload multiple images to the same tag in succession. Before queuing, if was possible to replace the image between sending the pending message and the image transfer to the tag, causing md5 mismatches and instability.

Solves #47
2024-01-29 00:49:52 +01:00
Nic Limper
8c4627007f removed simple_AP from build-test.yml 2024-01-28 23:08:33 +01:00
jjwbruijn
e563358370 Sorry bit much. Major rewrite of the 88MZ100 firmware, now with compression support. Added beta M2 2.7" (sleep current needs work) and 1.6"(200px). Probably broke M3 building, it's font files have moved to a new 'common' directory 2024-01-28 11:08:42 +01:00
Nic Limper
c2ab7d6057 crispy fonts / HS 3.5 BWY template fix / remove DATATYPE_IMG_RAW_1BPP_DIRECT 2024-01-27 23:49:14 +01:00
Jelmer
5e62b2de1b Update oepl-definitions.h 2024-01-26 22:29:07 +01:00
atc1441
62b87da8c2 Merge branch 'master' of https://github.com/jjwbruijn/OpenEPaperLink 2024-01-26 16:41:06 +01:00
atc1441
9608c6e417 Allow for complete offline ESP32-C6 Updates 2024-01-26 16:41:03 +01:00
Jelmer
86a68cbba4 backlogged fixes 2024-01-26 16:10:00 +01:00
Jelmer
80298ed4a1 Update tag_md5_db.json 2024-01-25 14:41:19 +01:00
Jelmer
d6b1cc0eca added compressed datatypes 2024-01-25 12:10:00 +01:00
Jelmer
90284d0a81 Merge pull request #208 from Reletiv/dev
Added Skadis mounts for HS TLSR
2024-01-25 00:24:34 +01:00
Reletiv
f88c05b279 Added Skadis Solum mounts
Added Skadis Solum mounts 1.54" and 2.9"
Credits to: tdroza
2024-01-24 23:59:45 +01:00
Reletiv
d435d12c30 Added Skadis mounts for HS 2024-01-24 21:43:13 +01:00
Jelmer
af3b6c53c8 Merge pull request #206 from justinotherguy/master
add gerber file for combined flex pcb for nano ap
2024-01-21 14:34:45 +01:00
Justin Otherguy
6af250efbf add gerber file for combined flex pcb
this file for combined flex pcb: antenna and connection between ESP32 S2 mini and tag, so it can be produced in one flex pcb.
combined file has been kinldy provided by 123tztz321 - thank you :)
2024-01-21 14:24:45 +01:00
Nic Limper
83bd0ec177 stability improvements
- changed ESPAsyncWebServer and AsyncTCP (both not properly maintained for more than 5 years) to more recent fork with bugfixes
- fixed concurrency issues in /imgupload. Hurts the upload performance a lot, but probably that's not a real issue. Parallel uploads are now possible (still within the max 5 TCP connection limit)
2024-01-21 11:04:35 +01:00
atc1441
fd13cccdd9 Update README.md 2024-01-19 11:03:24 +01:00
Nic Limper
abc84e18ff change in ledflash http call + minor fixes 2024-01-18 22:25:11 +01:00
atc1441
4edba16674 Another flashing Bug fix
In case the flashing of the C6 is started before the full Boot sequence the AP will end in a failed state
2024-01-15 16:39:24 +01:00
atc1441
7703f6ce6c Fixed interrupted flashing bug
While the C6 would be flashed the recovery would trigger as no Ping was received from the RF-AP
2024-01-15 15:37:24 +01:00
Nic Limper
f00761db94 small improvements
- added short date format definition in language.json
- changed english date format to mm/dd
- added lightgrey (4)/darkgrey (5)/pink (6) colors in jsontemplate (uses pattern dither)
- fixed ntp init timing
2024-01-14 14:24:44 +01:00
atc1441
2655d6d065 Update README.md 2024-01-13 01:24:17 +01:00
Jonas Niesner
e734052697 Update build-test.yml 2024-01-12 17:20:17 +01:00
atc1441
f7b13d3dcb Added a "failsave" recovery to get the RF-AP back up running 2024-01-11 22:36:47 +01:00
Nic Limper
69a40e47aa localisation of date format; tag reverts back to previous content type after sending firmware. 2024-01-11 21:17:35 +01:00
atc1441
b737eb60ed Update TLSR_HS_35_ALPHA.bin 2024-01-11 17:52:50 +01:00
atc1441
1d0186fed0 Enabled cached uploads on the TLSR FW 2024-01-11 17:51:49 +01:00
Nic Limper
d01825a323 autosave tagDB in localstorage of the browser 2024-01-11 14:50:35 +01:00
atc1441
5abbead90b Better SubGHz ESP32-C6 Stability by doing housekeeping every 60 Seconds 2024-01-11 09:10:58 +01:00
Nic Limper
3b294be08a cache control for tagtypes; uptime display in statusbar 2024-01-10 00:53:13 +01:00
atc1441
59d08ea21e Update of the ESP32-C6 SubGHz handling, working Beta 2024-01-09 22:48:18 +01:00
Nic Limper
d2135a57bd bugfix 2024-01-09 21:35:42 +01:00
Jelmer
e77556ee9c Added M2 2.7 jig - updated Hanshow Jigs 2024-01-09 21:19:46 +01:00
335 changed files with 31240 additions and 12414 deletions

View File

@@ -23,16 +23,11 @@ jobs:
- name: Install intelhex - name: Install intelhex
run: pip install --upgrade intelhex run: pip install --upgrade intelhex
- name: Build NRF firmware # - name: Build Simple_AP
run: | # run: |
cd ARM_Tag_FW/Newton_M3_nRF52811 # cd ESP32_AP-Flasher
pio run --environment Newton_M3_Universal # pio run --environment Simple_AP
# pio run --target buildfs --environment Simple_AP
- name: Build Simple_AP
run: |
cd ESP32_AP-Flasher
pio run --environment Simple_AP
pio run --target buildfs --environment Simple_AP
- name: Build OpenEPaperLink_Mini_AP - name: Build OpenEPaperLink_Mini_AP
run: | run: |
@@ -46,8 +41,14 @@ jobs:
pio run --environment OpenEPaperLink_AP_and_Flasher pio run --environment OpenEPaperLink_AP_and_Flasher
pio run --target buildfs --environment OpenEPaperLink_AP_and_Flasher pio run --target buildfs --environment OpenEPaperLink_AP_and_Flasher
- name: Build ESP32_S3_16_8_YELLOW_AP] - name: Build ESP32_S3_16_8_YELLOW_AP
run: | run: |
cd ESP32_AP-Flasher cd ESP32_AP-Flasher
pio run --environment ESP32_S3_16_8_YELLOW_AP pio run --environment ESP32_S3_16_8_YELLOW_AP
pio run --target buildfs --environment ESP32_S3_16_8_YELLOW_AP pio run --target buildfs --environment ESP32_S3_16_8_YELLOW_AP
- name: OpenEPaperLink_Mini_AP_v4
run: |
cd ESP32_AP-Flasher
pio run --environment OpenEPaperLink_Mini_AP_v4
pio run --target buildfs --environment OpenEPaperLink_Mini_AP_v4

View File

@@ -41,28 +41,10 @@ jobs:
run: | run: |
mkdir espbinaries mkdir espbinaries
- name: Zip web files # - name: Zip web files
run: | # run: |
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/ESP32_AP-Flasher # cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/ESP32_AP-Flasher
python gzip_wwwfiles.py # python gzip_wwwfiles.py
- name: Build firmware for Simple_AP
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment Simple_AP
pio run --target buildfs --environment Simple_AP
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/boot_app0.bin
cp .pio/build/Simple_AP/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/firmware.bin
cp .pio/build/Simple_AP/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/bootloader.bin
cp .pio/build/Simple_AP/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/partitions.bin
cp .pio/build/Simple_AP/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP/littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/Simple_AP
esptool.py --chip esp32 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x290000 littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp Simple_AP/firmware.bin espbinaries/Simple_AP.bin
cp Simple_AP/merged-firmware.bin espbinaries/Simple_AP_full.bin
- name: Build firmware for OpenEPaperLink_Mini_AP - name: Build firmware for OpenEPaperLink_Mini_AP
run: | run: |
@@ -176,6 +158,24 @@ jobs:
cp OpenEPaperLink_PoE_AP/firmware.bin espbinaries/OpenEPaperLink_PoE_AP.bin cp OpenEPaperLink_PoE_AP/firmware.bin espbinaries/OpenEPaperLink_PoE_AP.bin
cp OpenEPaperLink_PoE_AP/merged-firmware.bin espbinaries/OpenEPaperLink_PoE_AP_full.bin cp OpenEPaperLink_PoE_AP/merged-firmware.bin espbinaries/OpenEPaperLink_PoE_AP_full.bin
- name: Build firmware for OpenEPaperLink_Mini_AP_v4
run: |
cd ESP32_AP-Flasher
export PLATFORMIO_BUILD_FLAGS="-D BUILD_VERSION=${{ github.ref_name }} -D SHA=$GITHUB_SHA"
pio run --environment OpenEPaperLink_Mini_AP_v4
pio run --target buildfs --environment OpenEPaperLink_Mini_AP_v4
mkdir /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP_v4
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP_v4/boot_app0.bin
cp .pio/build/OpenEPaperLink_Mini_AP_v4/firmware.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP_v4/firmware.bin
cp .pio/build/OpenEPaperLink_Mini_AP_v4/bootloader.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP_v4/bootloader.bin
cp .pio/build/OpenEPaperLink_Mini_AP_v4/partitions.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP_v4/partitions.bin
cp .pio/build/OpenEPaperLink_Mini_AP_v4/littlefs.bin /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP_v4/littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink/OpenEPaperLink_Mini_AP_v4
esptool.py --chip esp32-s3 merge_bin -o merged-firmware.bin --flash_mode dio --flash_freq 80m --flash_size 16MB 0x0000 bootloader.bin 0x8000 partitions.bin 0xe000 boot_app0.bin 0x10000 firmware.bin 0x00910000 littlefs.bin
cd /home/runner/work/OpenEPaperLink/OpenEPaperLink
cp OpenEPaperLink_Mini_AP_v4/firmware.bin espbinaries/OpenEPaperLink_Mini_AP_v4.bin
cp OpenEPaperLink_Mini_AP_v4/merged-firmware.bin espbinaries/OpenEPaperLink_Mini_AP_v4_full.bin
- name: generate release json file - name: generate release json file
run: | run: |
mkdir jsonfiles mkdir jsonfiles

1
.gitignore vendored
View File

@@ -26,3 +26,4 @@
sdcc/sdcc sdcc/sdcc
ESP32_AP-Flasher/.vscode/extensions.json ESP32_AP-Flasher/.vscode/extensions.json
ARM_Tag_FW\Newton_M3_nRF52811\$PROJECT_DIR

6
.gitmodules vendored Normal file
View File

@@ -0,0 +1,6 @@
[submodule "ARM_Tag_FW/common/uzlib"]
path = ARM_Tag_FW/common/uzlib
url = https://github.com/pfalcon/uzlib.git
[submodule "ARM_Tag_FW/common/QRCode"]
path = ARM_Tag_FW/common/QRCode
url = https://github.com/ricmoo/QRCode

View File

@@ -1,4 +1,4 @@
build build
*.axf *.axf
# Allow # Allow
!*.bin #!*.bin

View File

@@ -1,98 +0,0 @@
const char font[256][40]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20
{0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x21
{0x00,0x00,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x22
{0x00,0x00,0x00,0x00,0x00,0x22,0x00,0x22,0x00,0x11,0x00,0x11,0x00,0x11,0xE0,0xFF,0x80,0x08,0x80,0x08,0x80,0x08,0xE0,0x7F,0x40,0x04,0x40,0x04,0x20,0x02,0x20,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x23
{0x00,0x00,0x00,0x04,0x00,0x1F,0x80,0x3F,0xC0,0x24,0xC0,0x04,0xC0,0x04,0x80,0x07,0x00,0x07,0x00,0x1C,0x00,0x1C,0x00,0x34,0x00,0x34,0x40,0x34,0xC0,0x1F,0x80,0x0F,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x24
{0x00,0x00,0x00,0x00,0xE0,0x81,0x30,0x43,0x30,0x23,0x30,0x13,0x30,0x0B,0x30,0x0B,0xE0,0x05,0x00,0x7A,0x00,0xCD,0x00,0xCD,0x80,0xCC,0x40,0xCC,0x20,0xCC,0x10,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x25
{0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x1F,0x80,0x19,0x80,0x19,0x80,0x0D,0x00,0x07,0xC0,0x03,0x60,0xC6,0x30,0xCE,0x30,0xCC,0x30,0x78,0x70,0x78,0xE0,0x7F,0xC0,0xEF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x26
{0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x27
{0x00,0x00,0x00,0x30,0x00,0x3C,0x00,0x0E,0x00,0x06,0x00,0x03,0x00,0x03,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x0E,0x00,0x3C,0x00,0x30,0x00,0x00}, // 0x28
{0x00,0x00,0xC0,0x00,0xC0,0x03,0x00,0x07,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x07,0xC0,0x03,0xC0,0x00,0x00,0x00}, // 0x29
{0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x60,0x33,0xE0,0x3C,0x00,0x00,0x80,0x0D,0xC0,0x19,0x80,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2A
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0xE0,0x7F,0xE0,0x7F,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2B
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x06,0x00,0x02,0x00,0x03,0x00,0x00}, // 0x2C
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3F,0xC0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2D
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2E
{0x00,0x00,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x00,0x00}, // 0x2F
{0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x1F,0xC0,0x30,0xC0,0x30,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xC0,0x30,0xC0,0x30,0x80,0x1F,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x30
{0x00,0x00,0x00,0x00,0x00,0x06,0xC0,0x07,0x60,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0xE0,0x7F,0xE0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x31
{0x00,0x00,0x00,0x00,0x80,0x0F,0xC0,0x1F,0x40,0x38,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0xC0,0x3F,0xC0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x32
{0x00,0x00,0x00,0x00,0x80,0x0F,0xC0,0x3F,0x40,0x30,0x00,0x30,0x00,0x18,0x80,0x0F,0x80,0x0F,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x30,0x40,0x38,0xC0,0x1F,0xC0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x33
{0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x1C,0x00,0x1E,0x00,0x1A,0x00,0x19,0x80,0x19,0xC0,0x18,0x40,0x18,0xE0,0x7F,0xE0,0x7F,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x34
{0x00,0x00,0x00,0x00,0x80,0x3F,0x80,0x3F,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x0F,0x80,0x1F,0x00,0x38,0x00,0x30,0x00,0x30,0x00,0x38,0x80,0x1F,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x35
{0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x1F,0xC0,0x11,0xC0,0x00,0x60,0x00,0x60,0x0E,0x60,0x1F,0xE0,0x38,0x60,0x30,0x60,0x30,0x60,0x30,0xC0,0x38,0xC0,0x1F,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x36
{0x00,0x00,0x00,0x00,0xC0,0x7F,0xC0,0x7F,0x00,0x60,0x00,0x30,0x00,0x10,0x00,0x18,0x00,0x0C,0x00,0x04,0x00,0x06,0x00,0x02,0x00,0x03,0x00,0x03,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x37
{0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x1F,0xC0,0x18,0xC0,0x18,0xC0,0x19,0x80,0x0F,0x00,0x07,0xC0,0x1E,0x60,0x38,0x60,0x30,0x60,0x30,0xE0,0x38,0xC0,0x1F,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x38
{0x00,0x00,0x00,0x00,0x80,0x07,0xC0,0x1F,0xE0,0x18,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x38,0xC0,0x37,0x80,0x33,0x00,0x30,0x00,0x18,0x40,0x1C,0xC0,0x0F,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x39
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x3A
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x06,0x00,0x02,0x00,0x03,0x00,0x00}, // 0x3B
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x70,0x00,0x3C,0x00,0x0E,0x80,0x03,0xE0,0x00,0x80,0x03,0x00,0x0E,0x00,0x3C,0x00,0x70,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x3C
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x7F,0xE0,0x7F,0x00,0x00,0x00,0x00,0xE0,0x7F,0xE0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x3D
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0xE0,0x00,0xC0,0x03,0x00,0x07,0x00,0x1C,0x00,0x70,0x00,0x1C,0x00,0x07,0xC0,0x03,0xE0,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x3E
{0x00,0x00,0x00,0x00,0xE0,0x0F,0xE0,0x3F,0x20,0x38,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x3F
{0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x31,0xC0,0x60,0x60,0x7C,0x30,0x66,0x30,0x63,0x30,0x63,0x30,0x73,0x30,0x73,0x30,0x6F,0x60,0xE6,0x60,0x00,0xC0,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x40
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x0F,0x00,0x0F,0x00,0x0D,0x80,0x19,0x80,0x19,0xC0,0x38,0xC0,0x30,0xC0,0x3F,0xE0,0x7F,0x60,0x60,0x60,0x60,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x41
{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x0F,0xE0,0x1F,0x60,0x18,0x60,0x18,0x60,0x0C,0xE0,0x07,0xE0,0x0F,0x60,0x18,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x42
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x80,0x7F,0xC0,0x41,0xC0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0xC0,0x43,0x80,0x7F,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x43
{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x0F,0xE0,0x1F,0x60,0x38,0x60,0x70,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x30,0x60,0x38,0xE0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x44
{0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x7F,0xC0,0x7F,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x3F,0xC0,0x3F,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x7F,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x45
{0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x7F,0xC0,0x7F,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x3F,0xC0,0x3F,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x46
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x80,0x7F,0xC0,0x41,0xC0,0x00,0x60,0x00,0x60,0x00,0x60,0x78,0x60,0x78,0x60,0x60,0xC0,0x60,0xC0,0x61,0x80,0x7F,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x47
{0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x3F,0xE0,0x3F,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x48
{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x1F,0xE0,0x1F,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0xE0,0x1F,0xE0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x49
{0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x1F,0x80,0x1F,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x1C,0xC0,0x0F,0xC0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x4A
{0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x70,0x60,0x38,0x60,0x1C,0x60,0x0E,0x60,0x06,0x60,0x03,0xE0,0x03,0x60,0x07,0x60,0x0E,0x60,0x1C,0x60,0x38,0x60,0x70,0x60,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x4B
{0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x7F,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x4C
{0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x70,0x70,0x70,0xF0,0x78,0xB0,0x68,0xB0,0x68,0xB0,0x6D,0x30,0x65,0x30,0x65,0x30,0x67,0x30,0x62,0x30,0x60,0x30,0x60,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x4D
{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x60,0xE0,0x60,0xE0,0x61,0xE0,0x61,0x60,0x63,0x60,0x67,0x60,0x66,0x60,0x6E,0x60,0x6C,0x60,0x78,0x60,0x78,0x60,0x70,0x60,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x4E
{0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0F,0xC0,0x1F,0xE0,0x38,0x70,0x70,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x70,0x70,0xE0,0x38,0xC0,0x1F,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x4F
{0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x1F,0xC0,0x3F,0xC0,0x70,0xC0,0x60,0xC0,0x60,0xC0,0x70,0xC0,0x3F,0xC0,0x0F,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x50
{0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0F,0xC0,0x1F,0xE0,0x38,0x70,0x70,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x60,0x30,0xE0,0x38,0xC0,0x1F,0x80,0x0F,0x00,0x38,0x00,0xF0,0x00,0x40,0x00,0x00}, // 0x51
{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xE0,0x1F,0x60,0x18,0x60,0x18,0x60,0x18,0x60,0x1C,0xE0,0x0F,0xE0,0x07,0x60,0x0E,0x60,0x1C,0x60,0x38,0x60,0x70,0x60,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x52
{0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0F,0xC0,0x1F,0x60,0x10,0x60,0x00,0xE0,0x00,0xC0,0x03,0x80,0x0F,0x00,0x3C,0x00,0x30,0x00,0x30,0x60,0x38,0xE0,0x1F,0xC0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x53
{0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0xF0,0xFF,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x54
{0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x38,0xC0,0x1F,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x55
{0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xC0,0x60,0x60,0x60,0x60,0xE0,0x60,0xC0,0x30,0xC0,0x30,0xC0,0x31,0x80,0x19,0x80,0x1B,0x00,0x0B,0x00,0x0F,0x00,0x0F,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x56
{0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xC0,0x30,0xC0,0x30,0xC0,0x20,0x46,0x20,0x46,0x20,0x6E,0x60,0x6F,0x60,0x69,0x60,0x69,0x60,0x39,0xC0,0x39,0xC0,0x39,0xC0,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x57
{0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xE0,0xE0,0x60,0xC0,0x30,0x80,0x19,0x80,0x0F,0x00,0x0F,0x00,0x06,0x00,0x0F,0x80,0x1D,0x80,0x19,0xC0,0x30,0x60,0x70,0x30,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x58
{0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xC0,0x60,0x60,0xC0,0x30,0xC0,0x31,0x80,0x19,0x00,0x0F,0x00,0x0F,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x59
{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x7F,0xE0,0x7F,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0xE0,0x7F,0xE0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x5A
{0x00,0x00,0x00,0x3F,0x00,0x3F,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x3F,0x00,0x3F,0x00,0x00}, // 0x5B
{0x00,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x00}, // 0x5C
{0x00,0x00,0xC0,0x0F,0xC0,0x0F,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0xC0,0x0F,0xC0,0x0F,0x00,0x00}, // 0x5D
{0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x0E,0x00,0x0A,0x00,0x0B,0x00,0x1B,0x80,0x11,0x80,0x31,0xC0,0x30,0xC0,0x20,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x5E
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0xF0,0xFF,0x00,0x00,0x00,0x00}, // 0x5F
{0x00,0x06,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x60
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x1F,0xC0,0x3F,0x40,0x30,0x00,0x30,0x00,0x30,0x80,0x3F,0xC0,0x30,0x60,0x30,0x60,0x38,0xE0,0xFF,0xC0,0xE7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x61
{0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x0E,0x60,0x1F,0xE0,0x39,0xE0,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x18,0xE0,0x1F,0x60,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x62
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xC0,0x3F,0xC0,0x21,0xE0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xE0,0x00,0xC0,0x01,0xC0,0x3F,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x63
{0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x80,0x37,0xC0,0x3F,0xC0,0x38,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x38,0xC0,0x3F,0x80,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x64
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x1F,0xC0,0x38,0x60,0x30,0xE0,0x3F,0xE0,0x3F,0x60,0x00,0x60,0x00,0xC0,0x20,0xC0,0x3F,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x65
{0x00,0x00,0x00,0x7E,0x00,0x7F,0x00,0x03,0x00,0x03,0xE0,0x7F,0xE0,0x7F,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x66
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x37,0xC0,0x3F,0xC0,0x38,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x38,0xC0,0x3F,0x80,0x37,0x00,0x30,0x40,0x38,0xC0,0x1F,0x80,0x0F}, // 0x67
{0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x1E,0x60,0x3F,0xE0,0x31,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x68
{0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0xC0,0x0F,0xC0,0x0F,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x69
{0x00,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x80,0x1F,0x80,0x1F,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x1C,0xC0,0x0F,0xC0,0x07}, // 0x6A
{0x00,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x70,0xC0,0x38,0xC0,0x1C,0xC0,0x0E,0xC0,0x06,0xC0,0x07,0xC0,0x0E,0xC0,0x1C,0xC0,0x38,0xC0,0x70,0xC0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x6B
{0x00,0x00,0xC0,0x0F,0xC0,0x0F,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x6C
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0x39,0xF0,0x7F,0x70,0x67,0x30,0x63,0x30,0x63,0x30,0x63,0x30,0x63,0x30,0x63,0x30,0x63,0x30,0x63,0x30,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x6D
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x1E,0x60,0x3F,0xE0,0x31,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x6E
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x3F,0xC0,0x30,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xC0,0x30,0xC0,0x3F,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x6F
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0F,0xE0,0x1F,0xE0,0x38,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x18,0xE0,0x1F,0x60,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00}, // 0x70
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x37,0xC0,0x3F,0xC0,0x38,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0xE0,0x38,0xC0,0x37,0x80,0x33,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30}, // 0x71
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3C,0xC0,0x3E,0xC0,0x23,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x72
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x1F,0xC0,0x1F,0xC0,0x00,0xC0,0x00,0xC0,0x03,0x00,0x1F,0x00,0x38,0x00,0x30,0x40,0x30,0xC0,0x1F,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x73
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0xE0,0x7F,0xE0,0x7F,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x7F,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x74
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x3C,0xE0,0x37,0xC0,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x75
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0xC0,0x20,0xC0,0x30,0xC0,0x30,0x80,0x11,0x80,0x19,0x80,0x19,0x00,0x0B,0x00,0x0F,0x00,0x0F,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x76
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xC0,0x30,0xC6,0x30,0xC6,0x20,0x4E,0x60,0x4F,0x60,0x49,0x60,0x69,0x60,0x79,0xC0,0x39,0xC0,0x30,0xC0,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x77
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x70,0xC0,0x30,0x80,0x19,0x80,0x0B,0x00,0x0F,0x00,0x06,0x00,0x0F,0x80,0x1D,0x80,0x19,0xC0,0x30,0x60,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x78
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0xC0,0x20,0xC0,0x30,0xC0,0x31,0x80,0x19,0x80,0x19,0x00,0x0B,0x00,0x0F,0x00,0x0F,0x00,0x06,0x00,0x06,0x00,0x02,0x00,0x03,0xC0,0x03,0xC0,0x01}, // 0x79
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x3F,0xE0,0x3F,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0xE0,0x3F,0xE0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x7A
{0x00,0x00,0x00,0x3C,0x00,0x3E,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0xC0,0x03,0xC0,0x03,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x3E,0x00,0x3C,0x00,0x00}, // 0x7B
{0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00}, // 0x7C
{0x00,0x00,0xC0,0x03,0xC0,0x07,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x3C,0x00,0x3C,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0xC0,0x07,0xC0,0x03,0x00,0x00}, // 0x7D
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x43,0xE0,0x7F,0x20,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x7E
{0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3F,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0xC0,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0x7F
};

View File

@@ -3,13 +3,17 @@ MZ_FLASHER=python ../88MZ100_Flasher/88MZ100_Uart_flasher.py
ARMGCC=/usr/bin/ ARMGCC=/usr/bin/
CC=$(ARMGCC)arm-none-eabi-gcc CC=$(ARMGCC)arm-none-eabi-gcc
GPLUSPLUS=$(ARMGCC)arm-none-eabi-g++
AS=$(ARMGCC)arm-none-eabi-as AS=$(ARMGCC)arm-none-eabi-as
OBJCOPY=$(ARMGCC)arm-none-eabi-objcopy OBJCOPY=$(ARMGCC)arm-none-eabi-objcopy
#-Wall #-Wall
CC_WARNING_FLAGS=-Wall -Wformat=0 -Wattributes -Wstrict-aliasing=0 CC_WARNING_FLAGS=-Wall -Wformat=0 -Wattributes -Wstrict-aliasing=0
CC_FlAGS=-mcpu=cortex-m3 -g -O0 -mthumb -fdata-sections -ffunction-sections -std=c99 CPP_FLAGS=-lstdc++ -mcpu=cortex-m3 -g -O3 -mthumb -fdata-sections -ffunction-sections -std=c++98 -std=gnu++0x
CC_END_FLAGS=-lc -lnosys -L. -T mz100.ld -fPIE --specs=nosys.specs -mcpu=cortex-m3 -mthumb -Wl,--gc-sections -O0 -flto -ffunction-sections -fdata-sections -DARM_GNU CPP0_FLAGS=-lstdc++ -mcpu=cortex-m3 -g -O0 -mthumb -fdata-sections -ffunction-sections -std=c++98 -std=gnu++0x
CC_FLAGS=-mcpu=cortex-m3 -g -O0 -mthumb -fdata-sections -ffunction-sections -std=c99
CC3_FLAGS=-mcpu=cortex-m3 -g -O3 -mthumb -fdata-sections -ffunction-sections -std=c99
CC_END_FLAGS=-lstdc++ -lc -lnosys -L. -T mz100/mz100.ld -fPIE --specs=nosys.specs -mcpu=cortex-m3 -mthumb -Wl,--gc-sections -O0 -flto -ffunction-sections -fdata-sections -DARM_GNU
C_SOURCES :=$(wildcard *.c) C_SOURCES :=$(wildcard *.c)
C_EXECUTABLE :=$(C_SOURCES:.c=) C_EXECUTABLE :=$(C_SOURCES:.c=)
@@ -27,44 +31,84 @@ uart: clean compile flash_uart
compile: compile:
@mkdir -p build # @mkdir -p build
@$(AS) -mcpu=cortex-m3 --gdwarf-2 -mthumb-interwork -o build/startup.o startup.S @$(AS) -mcpu=cortex-m3 --gdwarf-2 -mthumb-interwork -o build/startup.o startup.S
@$(CC) $(CC3_FLAGS) -c mz100/core_cm3.c -o build/core_cm3.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_ssp.c -o build/mz100_ssp.o
@$(CC) $(CC_FLAGS) -c mz100/mz100_wdt.c -o build/mz100_wdt.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_gpio.c -o build/mz100_gpio.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_driver.c -o build/mz100_driver.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_adc.c -o build/mz100_adc.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_flash.c -o build/mz100_flash.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_clock.c -o build/mz100_clock.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_rtc.c -o build/mz100_rtc.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_pinmux.c -o build/mz100_pinmux.o
@$(CC) $(CC_FLAGS) -c mz100/mz100_pmu.c -o build/mz100_pmu.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_qspi.c -o build/mz100_qspi.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_aes.c -o build/mz100_aes.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_gpt.c -o build/mz100_gpt.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_sleep.c -o build/mz100_sleep.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_uart.c -o build/mz100_uart.o
@$(CC) $(CC3_FLAGS) -c mz100/mz100_aon_ram.c -o build/mz100_aon_ram.o
@$(CC) $(CC3_FLAGS) -c mz100/printf.c -o build/printf.o
@$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c zigbee.c -o build/zigbee.o
# @$(CC) $(CC_FLAGS) $(CC_WARNING_FLAGS) -c ccm.c -o build/ccm.o
@$(CC) $(CC_FlAGS) -c core_cm3.c -o build/core_cm3.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/uzlib/src/adler32.c -o build/uz-adler32.o
@$(CC) $(CC_FlAGS) -c mz100_ssp.c -o build/mz100_ssp.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/uzlib/src/crc32.c -o build/uz-crc32.o
@$(CC) $(CC_FlAGS) -c mz100_wdt.c -o build/mz100_wdt.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/uzlib/src/defl_static.c -o build/uz-defl_static.o
@$(CC) $(CC_FlAGS) -c mz100_gpio.c -o build/mz100_gpio.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/uzlib/src/genlz77.c -o build/uz-genlz77.o
@$(CC) $(CC_FlAGS) -c mz100_driver.c -o build/mz100_driver.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/uzlib/src/tinfgzip.c -o build/uz-tinfgzip.o
@$(CC) $(CC_FlAGS) -c mz100_adc.c -o build/mz100_adc.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/uzlib/src/tinflate.c -o build/uz-tinflate.o
@$(CC) $(CC_FlAGS) -c mz100_flash.c -o build/mz100_flash.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/uzlib/src/tinfzlib.c -o build/uz-tinfzlib.o
@$(CC) $(CC_FlAGS) -c mz100_clock.c -o build/mz100_clock.o
@$(CC) $(CC_FlAGS) -c mz100_rtc.c -o build/mz100_rtc.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -Wno-unknown-pragmas -c ../common/QRCode/src/qrcode.c -o build/qrcode.o
@$(CC) $(CC_FlAGS) -c mz100_pinmux.c -o build/mz100_pinmux.o
@$(CC) $(CC_FlAGS) -c mz100_pmu.c -o build/mz100_pmu.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c compression.cpp -o build/compression.o
@$(CC) $(CC_FlAGS) -c mz100_qspi.c -o build/mz100_qspi.o
@$(CC) $(CC_FlAGS) -c mz100_aes.c -o build/mz100_aes.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c drawing.cpp -o build/drawing.o
@$(CC) $(CC_FlAGS) -c mz100_gpt.c -o build/mz100_gpt.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c epd_interface.cpp -o build/epd_interface.o
@$(CC) $(CC_FlAGS) -c mz100_sleep.c -o build/mz100_sleep.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c powermgt.cpp -o build/powermgt.o
@$(CC) $(CC_FlAGS) -c mz100_uart.c -o build/mz100_uart.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLASGS) -c oepl-protocol.cpp -o build/oepl-protocol.o
@$(CC) $(CC_FlAGS) -c mz100_aon_ram.c -o build/mz100_aon_ram.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c comms.c -o build/comms.o
@$(CC) $(CC_FlAGS) -c printf.c -o build/printf.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c ../common/md5.c -o build/md5.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c zigbee.c -o build/zigbee.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c settings.cpp -o build/settings.o
# @$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c ccm.c -o build/ccm.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c mz100/timer.c -o build/timer.o
# @$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c chars.c -o build/chars.o @$(CC) $(CC3_FLAGS) $(CC_WARNING_FLAGS) -c mz100/util.c -o build/util.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c drawing.c -o build/drawing.o @$(CC) $(CC_FLAGS) $(CC_WARNING_FLAGS) -c mz100/gpio.c -o build/gpio.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c powermgt.c -o build/powermgt.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c uc8159-var-m2.cpp -o build/uc8159-var-m2.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c syncedproto.c -o build/syncedproto.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c uc8176-var-m2.cpp -o build/uc8176-var-m2.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c comms.c -o build/comms.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c userinterface.cpp -o build/userinterface.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c settings.c -o build/settings.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c main.cpp -o build/main.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c timer.c -o build/timer.o @$(GPLUSPLUS) $(CPP_FLAGS) $(CC_WARNING_FLAGS) -c oepl_fs.cpp -o build/oepl_fs.o
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c util.c -o build/util.o @$(GPLUSPLUS) $(CC_END_FLAGS) $(CC_WARNING_FLAGS) \
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c gpio.c -o build/gpio.o build/main.o \
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c epd.c -o build/epd.o build/epd_interface.o \
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c userinterface.c -o build/userinterface.o build/oepl_fs.o\
@$(CC) $(CC_FlAGS) $(CC_WARNING_FLAGS) -c main.c -o build/main.o build/userinterface.o \
@$(CC) $(CC_END_FLAGS) $(CC_WARNING_FLAGS) build/main.o build/userinterface.o build/printf.o build/mz100_aon_ram.o build/zigbee.o build/drawing.o build/powermgt.o build/syncedproto.o build/comms.o build/settings.o build/timer.o build/util.o build/gpio.o build/epd.o build/mz100_sleep.o build/core_cm3.o build/mz100_ssp.o build/mz100_wdt.o build/mz100_gpio.o build/mz100_driver.o build/mz100_adc.o build/mz100_flash.o build/mz100_clock.o build/mz100_rtc.o build/mz100_pinmux.o build/mz100_pmu.o build/mz100_qspi.o build/mz100_aes.o build/mz100_gpt.o build/mz100_uart.o build/startup.o -o main.axf build/printf.o \
build/mz100_aon_ram.o \
build/zigbee.o \
build/compression.o \
build/drawing.o \
build/powermgt.o \
build/oepl-protocol.o \
build/comms.o \
build/settings.o \
build/timer.o \
build/util.o \
build/md5.o \
build/gpio.o \
build/uc8176-var-m2.o \
build/uc8159-var-m2.o \
build/mz100_sleep.o \
build/core_cm3.o \
build/qrcode.o \
build/uz-adler32.o build/uz-crc32.o build/uz-defl_static.o build/uz-genlz77.o build/uz-tinfgzip.o build/uz-tinflate.o build/uz-tinfzlib.o \
build/mz100_ssp.o build/mz100_wdt.o build/mz100_gpio.o build/mz100_driver.o build/mz100_adc.o build/mz100_flash.o build/mz100_clock.o build/mz100_rtc.o build/mz100_pinmux.o build/mz100_pmu.o build/mz100_qspi.o build/mz100_aes.o build/mz100_gpt.o build/mz100_uart.o \
build/startup.o -o main.axf
@$(OBJCOPY) -v -O binary main.axf main.bin @$(OBJCOPY) -v -O binary main.axf main.bin
@cat build/fs.img >> main.bin
clean: clean:
@rm -rf build/* @rm -rf build/*

View File

@@ -1,107 +0,0 @@
#ifndef _BITMAPS_H_
#define _BITMAPS_H_
// images generated by https://lvgl.io/tools/imageconverter, prepended with width, height. "CF_INDEXED_1_BIT"-mode, little-endian
#include <stdint.h>
#include "screen.h"
const uint8_t norf[] = {
24,
24,
0x00,
0x00,
0x00,
0x70,
0xe0,
0x00,
0x79,
0xe0,
0x00,
0x7f,
0xe0,
0x00,
0x3f,
0xc0,
0x00,
0x1f,
0x80,
0x00,
0x1f,
0x80,
0x00,
0x3f,
0xc0,
0x00,
0x7f,
0xe0,
0x0e,
0x79,
0xe0,
0x0a,
0x70,
0xe0,
0x0a,
0x00,
0x00,
0xea,
0x00,
0x00,
0xaa,
0x00,
0x00,
0xaa,
0x00,
0x0e,
0xaa,
0x00,
0x0a,
0xaa,
0x00,
0x0a,
0xaa,
0x00,
0xea,
0xaa,
0x00,
0xaa,
0xaa,
0x00,
0xaa,
0xaa,
0x0e,
0xaa,
0xaa,
0x0a,
0xaa,
0xaa,
0x0e,
0xee,
0xee,
0x00,
0x00,
0x00,
};
static const uint8_t batlow[] = {
24,17,
0x00, 0x00, 0x00,
0x7f, 0xff, 0xf8,
0x40, 0x00, 0x08,
0x40, 0x00, 0x08,
0x40, 0x00, 0x0e,
0x40, 0x00, 0x0a,
0x48, 0x00, 0x0a,
0x48, 0x00, 0x0a,
0x48, 0x64, 0x4a,
0x48, 0x94, 0x4a,
0x48, 0x95, 0x4a,
0x4e, 0x62, 0x8a,
0x40, 0x00, 0x0e,
0x40, 0x00, 0x08,
0x40, 0x00, 0x08,
0x7f, 0xff, 0xf8,
0x00, 0x00, 0x00,
};
#endif

View File

@@ -4,7 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include "proto.h" #include "proto.h"
#include "main.h" #include "main.h"
#include "gpio.h" #include "mz100/gpio.h"
#define eepromByte spiByte #define eepromByte spiByte
#define eepromPrvSelect() do { /*digitalWrite(FLASH_CS,LOW);*/ } while(0) #define eepromPrvSelect() do { /*digitalWrite(FLASH_CS,LOW);*/ } while(0)

View File

@@ -18,12 +18,12 @@ int8_t commsGetLastPacketRSSI(void) {
return mLastRSSI; return mLastRSSI;
} }
static inline void __attribute__((always_inline)) macCopy(uint8_t *restrict dst, const uint8_t *restrict src) { static inline void __attribute__((always_inline)) macCopy(uint8_t* dst, const uint8_t* src) {
((uint32_t *)dst)[0] = ((const uint32_t *)src)[0]; ((uint32_t *)dst)[0] = ((const uint32_t *)src)[0];
((uint32_t *)dst)[1] = ((const uint32_t *)src)[1]; ((uint32_t *)dst)[1] = ((const uint32_t *)src)[1];
} }
static inline bool __attribute__((always_inline)) macIsEq(const uint8_t *restrict dst, const uint8_t *restrict src) { static inline bool __attribute__((always_inline)) macIsEq(const uint8_t* dst, const uint8_t* src) {
return ((uint32_t *)dst)[0] == ((const uint32_t *)src)[0] && ((uint32_t *)dst)[1] == ((const uint32_t *)src)[1]; return ((uint32_t *)dst)[0] == ((const uint32_t *)src)[0] && ((uint32_t *)dst)[1] == ((const uint32_t *)src)[1];
} }

View File

@@ -0,0 +1,38 @@
#include "drawing.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include "epd_interface.h"
#include "mz100/printf.h"
#include "mz100/eeprom.h"
#include "oepl_fs.h"
#include "compression.h"
#include "../../oepl-definitions.h"
#include "../../oepl-proto.h"
#include "settings.h"
extern "C" {
extern void dump(const uint8_t *a, const uint16_t l);
#include "mz100/util.h"
#include "mz100/mz100_flash.h"
#include "../common/uzlib/src/uzlib.h"
}
#define MAX_WINDOW_SIZE 8192
#define ZLIB_CACHE_SIZE 512
uint32_t __attribute__((always_inline)) inline HAL_flashRead(uint32_t address, uint8_t *buffer, uint32_t num){
return FLASH_Read(FLASH_FAST_READ_QUAD_OUT, address, buffer, num);
}
#include "../common/compression.cpp"

View File

@@ -0,0 +1,9 @@
#pragma once
#define ENABLE_OEPLFS
#ifdef ENABLE_OEPLFS
#include "oepl_fs.h"
#endif
#include "../common/compression.h"

View File

@@ -1,68 +0,0 @@
#include "drawing.h"
#include <stdbool.h>
#include "board.h"
#include "eeprom.h"
#include "epd.h"
#include "printf.h"
#include "proto.h"
#include "screen.h"
#include "timer.h"
#include "util.h"
struct BitmapClutEntry {
uint8_t b, g, r, x;
};
uint8_t mPassNo = 0;
static uint8_t mClutMap[256];
static uint8_t mClutMapRed[256];
void drawImageAtAddress(uint32_t addr, uint8_t lut) {
struct EepromImageHeader *eih = (struct EepromImageHeader *)mClutMap;
eepromRead(addr, mClutMap, sizeof(struct EepromImageHeader));
switch (eih->dataType) {
case DATATYPE_IMG_RAW_1BPP:
printf("Doing raw 1bpp\n");
init_epd();
display_send_start(1);
for (uint32_t c = 0; c < (SCREEN_HEIGHT * (SCREEN_WIDTH / 8)); c++) {
if (c % 256 == 0) {
eepromRead(addr + sizeof(struct EepromImageHeader) + c, mClutMap, 256);
}
uint8_t curr_byte = mClutMap[c % 256]; // this one holds 8 pixel, we will translate them to 4 sendings
interleaveColor(curr_byte, 0x00);
}
display_send_stop();
epd_refresh_and_sleep(lut);
break;
case DATATYPE_IMG_RAW_2BPP:
printf("Doing raw 2bpp\n");
init_epd();
display_send_start(1);
for (uint32_t c = 0; c < (SCREEN_HEIGHT * (SCREEN_WIDTH / 8)); c++) {
if (c % 256 == 0) {
eepromRead(addr + sizeof(struct EepromImageHeader) + c, mClutMap, 256);
eepromRead(addr + sizeof(struct EepromImageHeader) + (SCREEN_HEIGHT * (SCREEN_WIDTH / 8)) + c, mClutMapRed, 256);
}
uint8_t curr_byte = mClutMap[c % 256]; // this one holds 8 pixel, we will translate them to 4 sendings
uint8_t curr_byteRed = mClutMapRed[c % 256]; // this one holds 8 pixel, we will translate them to 4 sendings
interleaveColor(curr_byte, curr_byteRed);
}
display_send_stop();
epd_refresh_and_sleep(lut);
break;
default: // prevent drawing from an unknown file image type
printf("Image with type 0x%02X was requested, but we don't know what to do with that currently...\n", eih->dataType);
return;
}
// addOverlay();
// drawWithSleep();
}

View File

@@ -0,0 +1,40 @@
// #pragma pack(1)
#include "drawing.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "epd_interface.h"
#include "mz100/printf.h"
#include "mz100/eeprom.h"
#include "compression.h"
#include "oepl_fs.h"
#include "../common/QRCode/src/qrcode.h"
#include "../../oepl-definitions.h"
#include "../../oepl-proto.h"
extern "C" {
extern void dump(const uint8_t *a, const uint16_t l);
#include "mz100/util.h"
#include "mz100/mz100_flash.h"
#include "../common/QRCode/src/qrcode.h"
}
#include "userinterface.h"
#include "epd_interface.h"
uint32_t __attribute__((always_inline)) inline HAL_flashRead(uint32_t address, uint8_t *buffer, uint32_t num){
return FLASH_Read(FLASH_FAST_READ_QUAD_OUT, address, buffer, num);
}
#include "../common/drawing.cpp"

View File

@@ -2,12 +2,13 @@
#define _DRAWING_H_ #define _DRAWING_H_
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#define DRAWING_MIN_BITMAP_SIZE (128) //minimum size we'll consider #define ENABLE_OEPLFS
void set_offline(bool state); #ifdef ENABLE_OEPLFS
void drawImageAtAddress(uint32_t addr, uint8_t lut); #include "oepl_fs.h"
void drawImageFromBuffer(uint8_t* buffer, const uint8_t lut); #endif
#include "../common/drawing.h"
#endif #endif

View File

@@ -1,48 +0,0 @@
#ifndef _EEPROM_H_
#define _EEPROM_H_
#include <stdint.h>
#define EEPROM_WRITE_PAGE_SZ 256 //max write size & alignment
#define EEPROM_ERZ_SECTOR_SZ 4096 //erase size and alignment
//pages are 4K in size
//an update can be stored in any 2 image slots
#define EEPROM_PAGE_SIZE (0x01000UL)
#define EEPROM_OS_START (0x00000UL)
#define EEPROM_OS_LEN (0x13FFFUL) //0xE820 of image, rounded up to 4K
#define EEPROM_IMG_START (0x17000UL)
#define EEPROM_IMG_EACH (0x1F000UL)
#define EEPROM_IMG_LEN (EEPROM_IMG_START + 0x13FFFUL)
#define EEPROM_UPDATE_START (0x17000UL) //same header as images
#define EEPROM_UPDATE_LEN (0x13FFFUL)
#define EEPROM_SETTINGS_AREA_START (0x14000UL)
#define EEPROM_SETTINGS_AREA_LEN (0x03000UL)
#define EEPROM_MAC_INFO_START (0x6c000UL) //not same as stock
#define EEPROM_MAC_INFO_LEN (0x01000UL)
#define EEPROM_IMG_INPROGRESS (0x7fffffff)
#define EEPROM_IMG_VALID (0x494d4721)
//#define EEPROM_PIECE_SZ (88)
struct EepromImageHeader { //each image space is 0x17000 bytes, we have space for ten of them
uint64_t version;
uint32_t validMarker;
uint32_t size;
uint8_t dataType;
uint32_t id;
//image data here
//we pre-erase so progress can be calculated by finding the first non-0xff byte
};
#endif

View File

@@ -1,818 +0,0 @@
#include "epd.h"
#include <stdbool.h>
#include <stdint.h>
// #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "12x20_horizontal_LSB_1.h"
#include "core_cm3.h"
#include "gpio.h"
#include "main.h"
#include "mz100_clock.h"
#include "mz100_gpio.h"
#include "mz100_pinmux.h"
#include "mz100_ssp.h"
#include "mz100_wdt.h"
#include "printf.h"
#include "stdarg.h"
#include "util.h"
#define EPD_PANEL_SETTING 0x00
#define EPD_POWER_SETTING 0x01
#define EPD_POWER_OFF 0x02
#define EPD_POWER_OFF_SEQUENCE 0x03
#define EPD_POWER_ON 0x04
#define EPD_BOOSTER_SOFT_START 0x06
#define EPD_DEEP_SLEEP 0x07
#define EPD_START_DATA 0x10
#define EPD_DATA_STOP 0x11
#define EPD_REFRESH 0x12
#define EPD_IMAGE_PROCESS 0x13
#define EPD_LUT_VCOM 0x20
#define EPD_LUT_B 0x21
#define EPD_LUT_W 0x22
#define EPD_LUT_G1 0x23
#define EPD_LUT_G2 0x24
#define EPD_LUT_R0 0x25
#define EPD_LUT_R1 0x26
#define EPD_LUT_R2 0x27
#define EPD_LUT_R3 0x28
#define EPD_LUT_XON 0x29
#define EPD_PLL_CONTROL 0x30
#define EPD_TEMP_CALIB 0x40
#define EPD_TEMP_SELECT 0x41
#define EPD_TEMP_WRITE 0x42
#define EPD_TEMP_READ 0x43
#define EPD_VCOM_DATA_INTERVAL 0x50
#define EPD_LPD 0x51
#define EPD_TCON_SET 0x60
#define EPD_TRES 0x61
#define EPD_SPI_FLASH_CONTROL 0x65
#define EPD_REVISION 0x70
#define EPD_GET_STATUS 0x71
#define EPD_AUTOMEASURE_VCOM 0x80
#define EPD_READ_VCOM 0x81
#define EPD_VCOM_DC_SET 0x82
#define EPD_SET_WINDOW 0x90
#define EPD_WAKE_EEPROM 0xAB
#define EPD_EEPROM_SLEEP 0xB9
#define EPD_UNKNOWN_1 0xE5
static uint8_t EPDtempBracket = 0;
#define CHAR_WIDTH_BYTES 2
#define CHAR_HEIGHT 20
#define CHAR_WIDTH 12
#define SCREEN_WIDTH 640
uint8_t buffer[CHAR_HEIGHT][640 / 8];
uint8_t charbuffer[CHAR_HEIGHT][CHAR_WIDTH_BYTES + 1];
#define CHAR_SPACING 1
#define EMPTY_SPACING 3
struct epd_colorlutpart {
uint8_t repeat;
uint8_t lvl0 : 4;
uint8_t lvl1 : 4;
uint8_t lvl2 : 4;
uint8_t lvl3 : 4;
uint8_t lvl4 : 4;
uint8_t lvl5 : 4;
uint8_t lvl6 : 4;
uint8_t lvl7 : 4;
uint8_t length[8];
} __packed;
struct epd_colorlut {
struct epd_colorlutpart part[20];
} __packed;
struct epd_vcomlutpart {
uint8_t repeat;
uint8_t lvl0 : 2;
uint8_t lvl1 : 2;
uint8_t lvl2 : 2;
uint8_t lvl3 : 2;
uint8_t lvl4 : 2;
uint8_t lvl5 : 2;
uint8_t lvl6 : 2;
uint8_t lvl7 : 2;
uint8_t length[8];
} __packed;
struct epd_vcomlut {
struct epd_vcomlutpart part[20];
} __packed;
struct epd_xonlutpart {
uint8_t repeat;
uint8_t lvl0 : 1;
uint8_t lvl1 : 1;
uint8_t lvl2 : 1;
uint8_t lvl3 : 1;
uint8_t lvl4 : 1;
uint8_t lvl5 : 1;
uint8_t lvl6 : 1;
uint8_t lvl7 : 1;
uint8_t length[8];
} __packed;
struct epd_xonlut {
struct epd_xonlutpart part[20];
} __packed;
void interleaveBW(uint8_t b) {
b ^= 0xFF;
uint8_t b_out = 0;
for (uint8_t shift = 0; shift < 4; shift++) {
b_out = 0;
if ((b >> 2 * shift) & 0x01) b_out |= 0x30; // 0x30
if ((b >> 2 * shift) & 0x02) b_out |= 0x03; // 0x03
display_tx_byte(b_out);
}
}
void interleaveColor(uint8_t b, uint8_t r) {
b ^= 0xFF;
uint8_t b_out = 0;
for (int8_t shift = 3; shift >= 0; shift--) {
b_out = 0;
if (((b >> 2 * shift) & 0x01) && ((r >> 2 * shift) & 0x01)) {
b_out |= 0x04; // 0x30
} else if ((b >> 2 * shift) & 0x01) {
b_out |= 0x03; // 0x30
} else if ((r >> 2 * shift) & 0x01) { // 4 or 5
b_out |= 0x04; // 0x30
} else {
}
if (((b >> 2 * shift) & 0x02) && ((r >> 2 * shift) & 0x02)) {
b_out |= 0x40; // 0x30
} else if ((b >> 2 * shift) & 0x02) {
b_out |= 0x30; // 0x30
} else if ((r >> 2 * shift) & 0x02) {
b_out |= 0x40; // 0x30
} else {
}
display_tx_byte(b_out);
}
}
void epdWrite(uint8_t reg, uint8_t len, ...) {
va_list valist;
va_start(valist, len);
epd_pin_enable(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_LOW);
SSP_SendData(SSP2_ID, reg);
for (int i = 0; i < 0xF; ++i)
__ISB();
GPIO_WritePinOutput(EPD_DC, GPIO_IO_HIGH);
for (uint8_t i = 0; i < len; i++) {
SSP_SendData(SSP2_ID, va_arg(valist, int));
}
for (int j = 0; j < 0xF; ++j)
__ISB();
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
epd_pin_enable(0);
va_end(valist);
}
void epd_reset() {
uint8_t v0 = 5;
printf("Resetting...");
while (1) {
GPIO_WritePinOutput(EPD_RESET, GPIO_IO_HIGH);
delay(100);
GPIO_WritePinOutput(EPD_RESET, GPIO_IO_LOW);
delay(3000);
GPIO_WritePinOutput(EPD_RESET, GPIO_IO_HIGH);
delay(3000);
if (GPIO_ReadPinLevel(EPD_BUSY))
break;
v0--;
if (!v0) {
printf("EPD reset failure\r\n");
break;
}
}
delay(5000);
printf(" Reset complete\n");
}
void EPD_cmd(char a1) {
epd_pin_enable(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_LOW);
SSP_SendData(SSP2_ID, a1);
for (int i = 0; i < 0xF; ++i)
__ISB();
epd_pin_enable(0);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_HIGH);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
}
void EPD_data(char a1) {
epd_pin_enable(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
SSP_SendData(SSP2_ID, a1);
for (int i = 0; i < 0xF; ++i)
__ISB();
epd_pin_enable(0);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
}
void spi_soft_send_byte(char a1) {
uint8_t v2 = 0;
do {
if ((a1 & 0x80) != 0)
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_HIGH);
else
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_LOW);
delay_us(1);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_HIGH);
delay_us(1);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
a1 *= 2;
v2++;
} while (v2 < 8);
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_LOW);
delay_us(1);
}
void BUSY_wait(unsigned int a1) {
unsigned int v2 = 0;
while (GPIO_ReadPinLevel(EPD_BUSY) == GPIO_IO_LOW) {
delay(10000);
v2++;
if (v2 > a1)
break;
if (((v2 % 1000) / 10) == 0)
WDT_RestartCounter();
}
}
void spi_soft_read_buffer(char a1, uint16_t readaddress, uint8_t *target, uint16_t length) {
char v9;
unsigned int v10;
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_LOW);
spi_soft_send_byte(3);
spi_soft_send_byte(a1);
spi_soft_send_byte(readaddress >> 8);
spi_soft_send_byte(readaddress);
delay_us(5);
for (uint16_t i = 0; i < length; i++) {
v9 = 0;
v10 = 0;
do {
v9 *= 2;
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
delay_us(1);
if (GPIO_ReadPinLevel(EPD_MISO))
v9 |= 1u;
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_HIGH);
delay_us(1);
v10++;
} while (v10 < 8);
delay_us(1);
*target++ = v9;
}
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_HIGH);
}
int spi_soft_read_byte() {
int v0;
unsigned int v1;
v0 = 0;
GPIO_WritePinOutput(EPD_BS, GPIO_IO_HIGH);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
delay_us(1);
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_HIGH);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_HIGH);
delay_us(1);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
delay_us(1);
GPIO_SetPinDir(EPD_MOSI, GPIO_INPUT);
GPIO_PinMuxFun(EPD_MOSI, 0);
delay_us(3);
v1 = 0;
do {
v0 = (uint8_t)(2 * v0);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_HIGH);
if (GPIO_ReadPinLevel(EPD_MOSI))
v0 |= 1u;
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
delay_us(1);
v1++;
} while (v1 < 8);
GPIO_SetPinDir(EPD_MOSI, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_MOSI, 0);
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_LOW);
delay_us(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
delay_us(1);
GPIO_WritePinOutput(EPD_BS, GPIO_IO_LOW);
return v0;
}
uint8_t getTempBracket() {
uint8_t v0;
uint8_t v1;
uint8_t temptable[40];
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(1);
delay_us(1000);
spi_soft_read_buffer(0, 25002, temptable, 10);
delay_us(1000);
delay_us(1000);
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(0);
EPD_cmd(EPD_TEMP_CALIB);
BUSY_wait(0xAu);
v0 = spi_soft_read_byte();
v1 = (uint8_t)(2 * v0) + ((uint8_t)spi_soft_read_byte() >> 7);
uint8_t bracket = 0;
for (int i = 0; i < 9; i++) {
if ((((char)v1 - (uint8_t)temptable[i]) & 0x80) != 0) {
bracket = i;
break;
}
}
return bracket;
}
void loadFrameRatePLL(uint8_t bracket) {
uint8_t pllvalue;
uint8_t plltable[12];
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(1);
delay_us(1000);
spi_soft_read_buffer(0, 25039, plltable, 10);
delay_us(1000);
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(0);
pllvalue = plltable[bracket];
EPD_cmd(EPD_PLL_CONTROL);
EPD_data(pllvalue);
}
extern void dump(const uint8_t *a, const uint16_t l);
void loadTempVCOMDC(uint8_t bracket) {
uint8_t vcomvalue;
uint8_t vcomtable[12];
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(1);
delay_us(1000);
spi_soft_read_buffer(0, 25049, vcomtable, 10);
delay_us(1000);
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(0);
vcomvalue = vcomtable[bracket];
EPD_cmd(EPD_VCOM_DC_SET);
EPD_data(vcomvalue);
}
uint8_t *loadLUT(uint8_t index, uint8_t bracket) {
uint16_t adr = 0;
uint16_t len = 0;
uint8_t *lutBuffer;
switch (index) {
case EPD_LUT_VCOM:
// VCOM LUT
adr = 20800 + (220 * bracket);
len = 220;
break;
case EPD_LUT_B:
case EPD_LUT_W:
case EPD_LUT_G1:
case EPD_LUT_G2:
case EPD_LUT_R0:
case EPD_LUT_R1:
case EPD_LUT_R2:
case EPD_LUT_R3:
adr = (bracket * 2080);
adr += (index - 0x21) * 260;
len = 260;
break;
case EPD_LUT_XON:
// XON LUT
adr = 23000 + (200 * bracket);
len = 200;
break;
}
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(1);
delay_us(1000);
lutBuffer = malloc(len);
if (lutBuffer) spi_soft_read_buffer(0, adr, lutBuffer, len);
delay_us(1000);
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(0);
return lutBuffer;
}
void shiftRightByX(uint8_t *data, int X, int N) {
if (X < 0 || X >= 8) {
// Invalid shift value, X should be between 0 and 7 (inclusive)
return;
}
// Perform the shift operation on each byte in the range
for (int i = 0; i < N; i++) {
data[i] = (data[i] >> X) | ((data[i + 1] & ((1 << X) - 1)) << (8 - X));
}
}
void shiftLeftByX(uint8_t *data, int X, int N) {
if (X < 0 || X >= 8) {
// Invalid shift value, X should be between 0 and 7 (inclusive)
return;
}
// Perform the shift operation on each byte in the range
for (int i = N - 1; i >= 0; i--) {
data[i] = (data[i] << X) | ((data[i - 1] >> (8 - X)) & ((1 << X) - 1));
}
}
uint16_t loadCharacter(uint8_t currentChar, uint16_t curX, bool first) {
currentChar -= 0x20;
memset(charbuffer, 0, sizeof(charbuffer));
for (uint8_t d = 0; d < CHAR_HEIGHT; d++) {
for (uint8_t c = 0; c < CHAR_WIDTH_BYTES; c++) {
charbuffer[d][c] = font[currentChar][c + (2 * d)];
}
}
// find amount of left whitespace and compensate
uint8_t leftShift = 0;
for (uint8_t left = 0; left < CHAR_WIDTH; left++) {
bool leftAdjusted = false;
for (uint8_t height = 0; height < CHAR_HEIGHT; height++) {
if (charbuffer[height][0] & 0x01) {
leftAdjusted = true;
break;
}
}
if (leftAdjusted) {
break;
} else {
for (uint8_t height = 0; height < CHAR_HEIGHT; height++) {
shiftRightByX(&(charbuffer[height][0]), 1, CHAR_WIDTH_BYTES);
}
leftShift++;
}
}
// find width for character
uint8_t width = 0;
for (int8_t curBit = CHAR_WIDTH + 1; curBit > 0; curBit--) {
bool widthFound = false;
for (uint8_t height = 0; height < CHAR_HEIGHT; height++) {
if (charbuffer[height][curBit / 8] & (1 << (curBit % 8))) {
widthFound = true;
break;
}
}
if (widthFound) {
width = curBit + 1;
break;
}
}
if (!first) {
curX += CHAR_SPACING;
}
for (uint8_t height = 0; height < CHAR_HEIGHT; height++) {
shiftLeftByX(&(charbuffer[height][0]), curX % 8, CHAR_WIDTH_BYTES + 1);
}
for (uint8_t d = 0; d < CHAR_HEIGHT; d++) {
for (uint8_t c = 0; c < CHAR_WIDTH_BYTES + 1; c++) {
buffer[d][(curX / 8) + c] |= charbuffer[d][c];
}
}
if (width == 0) width = EMPTY_SPACING;
curX += width;
return curX;
}
void dumpBuffer(uint16_t xloc, uint16_t yloc, uint16_t width) {
xloc = SCREEN_WIDTH - xloc;
setDisplayWindow(xloc - width, yloc, xloc, yloc + CHAR_HEIGHT);
display_send_start(0);
for (uint8_t curY = 0; curY < CHAR_HEIGHT; curY++) {
for (uint16_t curX = 0; curX < width; curX += 8) {
interleaveBW(buffer[curY][curX / 8]);
}
}
display_send_stop();
}
void loadLUTSfromEEPROM(uint8_t bracket) {
for (uint8_t c = EPD_LUT_B; c <= EPD_LUT_R3; c++) {
struct epd_colorlut *colorlut = (struct epd_colorlut *)loadLUT(c, bracket);
for (uint8_t d = 0; d < 8; d++) {
colorlut->part[1].length[d] = 1;
colorlut->part[0].length[d] = 1;
}
for (uint8_t part = 0; part < 4; part++) {
if (colorlut->part[part].repeat) colorlut->part[part].repeat = 1;
}
for (uint8_t part = 4; part < 20; part++) {
if (colorlut->part[part].repeat) colorlut->part[part].repeat = 0;
}
lutBeginTX(c);
for (uint16_t d = 0; d < 260; d++) {
display_tx_byte(((uint8_t *)colorlut)[d]);
}
lutEndTX();
if (colorlut) free(colorlut);
}
struct epd_vcomlut *vcomlut = (struct epd_vcomlut *)loadLUT(EPD_LUT_VCOM, bracket);
for (uint8_t part = 0; part < 20; part++) {
if (vcomlut->part[part].repeat) vcomlut->part[part].repeat = 0;
}
lutBeginTX(EPD_LUT_VCOM);
for (uint16_t d = 0; d < 220; d++) {
display_tx_byte(((uint8_t *)vcomlut)[d]);
}
lutEndTX();
if (vcomlut) free(vcomlut);
struct epd_xonlut *xonlut = (struct epd_xonlut *)loadLUT(EPD_LUT_XON, bracket);
// memset(&(xonlut->part[0].repeat), 0x00, sizeof(struct epd_xonlutpart));
// memset(&(xonlut->part[1].repeat), 0x00, sizeof(struct epd_xonlutpart));
for (uint8_t part = 0; part < 20; part++) {
if (xonlut->part[part].repeat) xonlut->part[part].repeat = 0;
}
lutBeginTX(EPD_LUT_XON);
for (uint16_t d = 0; d < 200; d++) {
display_tx_byte(((uint8_t *)xonlut)[d]);
}
lutEndTX();
if (xonlut) free(xonlut);
}
void init_GPIO_EPD() {
SSP_CFG_Type v0;
SPI_Param_Type spiParaStruct;
GPIO_PinMuxFun(EPD_MOSI, 0);
GPIO_SetPinDir(EPD_MOSI, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_CLK, 0);
GPIO_SetPinDir(EPD_CLK, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_CS, 0);
GPIO_SetPinDir(EPD_CS, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_BUSY, 0);
GPIO_SetPinDir(EPD_BUSY, GPIO_INPUT);
GPIO_PinModeConfig(EPD_BUSY, PINMODE_PULLUP);
GPIO_PinMuxFun(EPD_RESET, 0);
GPIO_SetPinDir(EPD_RESET, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_RESET, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_DC, 0);
GPIO_SetPinDir(EPD_DC, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_BS, 0);
GPIO_SetPinDir(EPD_BS, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_BS, GPIO_IO_LOW);
GPIO_PinMuxFun(EPD_HLT_CTRL, 0);
GPIO_SetPinDir(EPD_HLT_CTRL, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_MISO, 0);
GPIO_SetPinDir(EPD_MISO, GPIO_INPUT);
GPIO_PinModeConfig(EPD_MISO, PINMODE_DEFAULT);
memset(&v0, 0, 9);
v0.timeOutVal = 0;
SSP_Init(SSP2_ID, &v0);
spiParaStruct.spiClkPhase = SPI_SCPHA_1;
spiParaStruct.spiClkPolarity = SPI_SCPOL_LOW;
SPI_Config(SSP2_ID, &spiParaStruct);
CLK_I2SClkSrc(CLK_I2S_XTAL32M);
CLK_SSPClkSrc(CLK_SSP_ID_2, CLK_SSP_I2S);
CLK_I2SClkDivider(1, 1);
}
void fillWindow(uint16_t x, uint16_t y, uint16_t xe, uint16_t ye, uint8_t color) {
setDisplayWindow(x, y, xe, ye);
display_send_start(0);
for (uint32_t c = 0; c < (xe - x) * (ye - y) / 8; c++) {
interleaveBW(0x00);
}
display_send_stop();
}
void epd_refresh_and_sleep(uint8_t lut) {
if (lut) {
epdWrite(EPD_PANEL_SETTING, 2, 0xC3, 0x88); // 0xC3-0x88 // lut from register
loadLUTSfromEEPROM(EPDtempBracket);
} else {
epdWrite(EPD_PANEL_SETTING, 2, 0xC3, 0x08); // 0xC3-0x88 // lut from EEPROM
epdWrite(EPD_UNKNOWN_1, 1, 0x03); // load lut, probably
}
// epdPrintf(50,100,false,"Blaat! Dit is een test %d", 6);
EPD_cmd(EPD_REFRESH);
unsigned int v2 = 0;
while (GPIO_ReadPinLevel(EPD_BUSY) == GPIO_IO_HIGH) {
WDT_RestartCounter();
delay(10000);
v2++;
if (v2 > 10)
break;
}
do_sleeped_epd_refresh();
init_GPIO_EPD();
epd_reset();
// epd_reset();
EPD_cmd(EPD_POWER_SETTING);
EPD_data(2);
EPD_data(0);
EPD_data(0);
EPD_data(0);
delay_us(50000);
EPD_cmd(EPD_POWER_OFF);
delay_us(100000);
BUSY_wait(0x32u);
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(1);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_LOW);
spi_soft_send_byte(EPD_EEPROM_SLEEP);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_HIGH);
EPD_cmd(EPD_SPI_FLASH_CONTROL);
EPD_data(0);
EPD_cmd(EPD_DEEP_SLEEP);
EPD_data(0xA5);
}
void epd_pin_enable(int a1) {
if (a1) {
GPIO_PinMuxFun(EPD_CLK, GPIO22_SSP2_SCK);
GPIO_PinMuxFun(EPD_MOSI, GPIO12_SSP2_TXD);
GPIO_PinMuxFun(EPD_MISO, GPIO13_SSP2_RXD);
SSP_Enable(SSP2_ID);
} else {
SSP_Disable(SSP2_ID);
GPIO_PinMuxFun(EPD_MOSI, 0);
GPIO_SetPinDir(EPD_MOSI, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_CLK, 0);
GPIO_SetPinDir(EPD_CLK, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_MISO, 0);
GPIO_SetPinDir(EPD_MISO, GPIO_INPUT);
GPIO_PinModeConfig(EPD_MISO, PINMODE_DEFAULT);
}
}
void lutBeginTX(uint8_t reg) {
EPD_cmd(reg);
epd_pin_enable(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
}
void lutEndTX() {
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
epd_pin_enable(0);
}
void setDisplayWindow(uint16_t x, uint16_t y, uint16_t xe, uint16_t ye) {
x &= 0xFFF8; // byte boundary
xe = (xe - 1) | 0x0007; // byte boundary - 1
EPD_cmd(0x91);
epdWrite(0x90, 9, x / 256, x % 256, xe / 256, xe % 256, y / 256, y % 256, ye / 256, ye % 256, 0x01);
}
void display_tx_byte(uint8_t data) {
SSP_SendData(SSP2_ID, data);
}
void display_send_start(uint8_t inverted) {
EPD_cmd(EPD_START_DATA);
epd_pin_enable(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
}
void display_send_stop() {
for (int i = 0; i < 0xF; ++i)
__ISB();
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
epd_pin_enable(0);
}
void init_epd(void) {
printf("EPD Powerup begin\n");
init_GPIO_EPD();
epd_reset();
EPD_cmd(EPD_POWER_ON);
BUSY_wait(0x32u);
// wake the eeprom
epdWrite(EPD_SPI_FLASH_CONTROL, 1, 0x01);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_LOW);
epdWrite(EPD_WAKE_EEPROM, 0x00);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_HIGH);
epdWrite(EPD_SPI_FLASH_CONTROL, 1, 0x00);
epdWrite(EPD_POWER_SETTING, 4, 0x37, 0x00, 0x05, 0x05); // 0x37 - 00- 05 05
// epdWrite(EPD_POWER_SETTING, 4, 0x07, 0x00, 0x05, 0x05); // 0x37 - 00- 05 05
epdWrite(EPD_PANEL_SETTING, 2, 0xC3, 0x08); // 0xC3-0x88 // lut from EEPROM
epdWrite(EPD_POWER_OFF_SEQUENCE, 1, 0x00);
epdWrite(EPD_BOOSTER_SOFT_START, 0x03, 199, 204, 45);
epdWrite(EPD_PLL_CONTROL, 0x01, 60);
epdWrite(EPD_TEMP_SELECT, 0x01, 0x00);
epdWrite(EPD_VCOM_DATA_INTERVAL, 0x01, 119);
epdWrite(EPD_TCON_SET, 0x01, 34);
epdWrite(EPD_TRES, 0x04, 2, 128, 1, 128);
EPDtempBracket = getTempBracket();
loadFrameRatePLL(EPDtempBracket);
loadTempVCOMDC(EPDtempBracket);
}
void epdPrintf(uint16_t x, uint16_t y, bool color, const char *c, ...) {
// Render the text
char out_buffer[96];
uint16_t curX = 0;
memset(buffer, 0, sizeof(buffer));
memset(charbuffer, 0, sizeof(charbuffer));
va_list lst;
va_start(lst, c);
vsnprintf(out_buffer, 256, c, lst);
va_end(lst);
curX = x % 8;
char *text = (char *)out_buffer;
memset(charbuffer, 0, sizeof(charbuffer));
curX = loadCharacter(*text, curX, true);
text++;
while (*text != '\0') {
memset(charbuffer, 0, sizeof(charbuffer));
curX = loadCharacter(*text, curX, false);
text++;
}
x /= 8;
x *= 8;
dumpBuffer(x, y, curX);
}
void drawImg(uint16_t x, uint16_t y, const uint8_t *img) {
uint16_t width = img[0];
uint16_t height = img[1];
img += 2;
setDisplayWindow(x, y, x + width, y + height);
display_send_start(0);
for (uint8_t curY = 0; curY < height; curY++) {
for (uint16_t curX = 0; curX < width; curX += 8) {
interleaveColor(*(img++), 0x00);
}
}
display_send_stop();
}

View File

@@ -1,58 +0,0 @@
#pragma once
//#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#define DISPLAY_WIDTH (640)
#define DISPLAY_HEIGHT (384)
#define DISPLAY_WIDTH_MM (164)
#define DISPLAY_HEIGHT_MM (97)
#define MAGNIFY1 3
#define MAGNIFY2 2
#define MAGNIFY3 1
#define BACK_COLOR 3
#define FORE_COLOR_1 0
#define FORE_COLOR_2 4
#define FORE_COLOR_3 0
#define EPD_LUT_DEFAULT 0
#define EPD_LUT_NO_REPEATS 1
#define EPD_LUT_FAST_NO_REDS 2
#define EPD_LUT_FAST 3
#define EPD_DIRECTION_X false
#define EPD_DIRECTION_Y true
#define EPD_SIZE_SINGLE false
#define EPD_SIZE_DOUBLE true
#define EPD_COLOR_RED true
#define EPD_COLOR_BLACK false
void init_GPIO_EPD();
void display_send_buffer();
void epd_refresh_and_sleep(uint8_t lut);
void display_tx_byte(uint8_t data);
void display_send_start(uint8_t inverted);
void display_send_stop();
void setDisplayWindow(uint16_t x, uint16_t y, uint16_t xe, uint16_t ye);
void init_epd();
void refresh_epd();
void lutBeginTX(uint8_t reg);
void lutEndTX();
void epd_pin_enable(int a1);
void fillWindow(uint16_t x, uint16_t y, uint16_t xe, uint16_t ye, uint8_t color);
void epdPrintf(uint16_t x, uint16_t y, bool color, const char* c, ...);
void interleaveColor(uint8_t b, uint8_t r);
void interleaveBW(uint8_t);
void drawImg(uint16_t x, uint16_t y, const uint8_t *img);

View File

@@ -0,0 +1,278 @@
#include "drawing.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "epd_interface.h"
#include "uc8159-var-m2.h"
#include "uc8176-var-m2.h"
#include "mz100/printf.h"
#include "mz100/eeprom.h"
#include "main.h"
extern "C" {
#include "mz100/mz100_clock.h"
#include "mz100/mz100_gpio.h"
#include "mz100/mz100_pinmux.h"
#include "mz100/mz100_ssp.h"
#include "mz100/mz100_wdt.h"
#include "mz100/util.h"
}
#include "settings.h"
#include "../../oepl-definitions.h"
#include "../../oepl-proto.h"
__attribute__((section(".aonshadow"))) epdInterface *epd;
__attribute__((section(".aonshadow"))) tagSpecs tag;
epdInterface::~epdInterface() {
}
void epdSetup() {
switch (tagProfile.controllerType) {
case 0:
epd = new uc8159;
break;
case 1:
epd = new uc8176;
break;
}
epd->effectiveXRes = tagProfile.xRes;
epd->effectiveYRes = tagProfile.yRes;
epd->Xres = tagProfile.xRes;
epd->Yres = tagProfile.yRes;
epd->bpp = tagProfile.bpp;
epd->epdSetup();
}
void epdEnterSleep() {
epd->epdEnterSleep();
delete epd;
}
void draw() {
epd->draw();
}
void drawNoWait() {
epd->drawNoWait();
}
void epdWaitRdy() {
epd->epdWaitRdy();
}
void selectLUT(uint8_t sel) {
epd->selectLUT(sel);
}
static void busyWaitUntilHigh(uint32_t timeout) {
uint32_t v2 = 0;
while (GPIO_ReadPinLevel(EPD_BUSY) == GPIO_IO_LOW) {
delay(50);
v2++;
if (v2 > timeout)
break;
if (((v2 % 1000) / 10) == 0)
WDT_RestartCounter();
}
}
static void busyWaitUntilLow(uint32_t timeout) {
uint32_t v2 = 0;
while (GPIO_ReadPinLevel(EPD_BUSY) == GPIO_IO_HIGH) {
delay(50);
v2++;
if (v2 > timeout)
break;
if (((v2 % 1000) / 10) == 0)
WDT_RestartCounter();
}
}
void busyWaitUntil(bool high, uint32_t timeout) {
if (high)
busyWaitUntilHigh(timeout);
else
busyWaitUntilLow(timeout);
}
void softSPIWriteByte(char byteOut) {
uint8_t loopCount = 0;
do {
if ((byteOut & 0x80) != 0)
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_HIGH);
else
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_LOW);
delay_us(1);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_HIGH);
delay_us(1);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
byteOut *= 2;
loopCount++;
delay_us(1);
} while (loopCount < 8);
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_LOW);
delay_us(1);
}
uint8_t softSPIReadByte() {
uint8_t readByte = 0;
uint8_t loopCount = 0;
GPIO_WritePinOutput(EPD_BS, GPIO_IO_HIGH);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
delay_us(1);
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_HIGH);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_HIGH);
delay_us(1);
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
delay_us(1);
GPIO_SetPinDir(EPD_MOSI, GPIO_INPUT);
GPIO_PinMuxFun(EPD_MOSI, PINMUX_FUNCTION_0);
delay_us(3);
do {
readByte *= 2;
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_HIGH);
if (GPIO_ReadPinLevel(EPD_MOSI))
readByte |= 1u;
GPIO_WritePinOutput(EPD_CLK, GPIO_IO_LOW);
delay_us(1);
// delay(1);
loopCount++;
} while (loopCount < 8);
GPIO_SetPinDir(EPD_MOSI, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_MOSI, PINMUX_FUNCTION_0);
GPIO_WritePinOutput(EPD_MOSI, GPIO_IO_LOW);
delay_us(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
delay_us(1);
GPIO_WritePinOutput(EPD_BS, GPIO_IO_LOW);
// delay(1);
delay_us(1);
return readByte;
}
void enableHardSPI(bool enable) {
if (enable) {
GPIO_PinMuxFun(EPD_CLK, GPIO22_SSP2_SCK);
GPIO_PinMuxFun(EPD_MOSI, GPIO12_SSP2_TXD);
GPIO_PinMuxFun(EPD_MISO, GPIO13_SSP2_RXD);
SSP_Enable(SSP2_ID);
} else {
SSP_Disable(SSP2_ID);
GPIO_PinMuxFun(EPD_MOSI, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_MOSI, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_CLK, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_CLK, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_MISO, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_MISO, GPIO_INPUT);
GPIO_PinModeConfig(EPD_MISO, PINMODE_DEFAULT);
}
}
void initEPDGPIO() {
SSP_CFG_Type v0;
SPI_Param_Type spiParaStruct;
GPIO_PinMuxFun(EPD_MOSI, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_MOSI, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_CLK, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_CLK, GPIO_OUTPUT);
GPIO_PinMuxFun(EPD_CS, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_CS, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_BUSY, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_BUSY, GPIO_INPUT);
GPIO_PinModeConfig(EPD_BUSY, PINMODE_PULLUP);
GPIO_PinMuxFun(EPD_RESET, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_RESET, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_RESET, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_DC, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_DC, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_BS, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_BS, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_BS, GPIO_IO_LOW);
GPIO_PinMuxFun(EPD_HLT_CTRL, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_HLT_CTRL, GPIO_OUTPUT);
GPIO_WritePinOutput(EPD_HLT_CTRL, GPIO_IO_HIGH);
GPIO_PinMuxFun(EPD_MISO, PINMUX_FUNCTION_0);
GPIO_SetPinDir(EPD_MISO, GPIO_INPUT);
GPIO_PinModeConfig(EPD_MISO, PINMODE_DEFAULT);
memset(&v0, 0, 9);
v0.timeOutVal = 0;
SSP_Init(SSP2_ID, &v0);
spiParaStruct.spiClkPhase = SPI_SCPHA_1;
spiParaStruct.spiClkPolarity = SPI_SCPOL_LOW;
SPI_Config(SSP2_ID, &spiParaStruct);
CLK_I2SClkSrc(CLK_I2S_XTAL32M);
CLK_SSPClkSrc(CLK_SSP_ID_2, CLK_SSP_I2S);
CLK_I2SClkDivider(1, 1);
}
void epdWrite(uint8_t reg, uint8_t len, ...) {
va_list valist;
va_start(valist, len);
enableHardSPI(true);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_LOW);
SSP_SendData(SSP2_ID, reg);
while (SSP_GetTxFifoLevel(SSP2_ID))
;
GPIO_WritePinOutput(EPD_DC, GPIO_IO_HIGH);
for (uint8_t i = 0; i < len; i++) {
SSP_SendData(SSP2_ID, va_arg(valist, int));
}
while (SSP_GetTxFifoLevel(SSP2_ID))
;
delay_us(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
enableHardSPI(false);
va_end(valist);
}
void epdBlockWrite(uint8_t reg, uint8_t *buffer, uint16_t len) {
enableHardSPI(true);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_LOW);
SSP_SendData(SSP2_ID, reg);
while (SSP_GetTxFifoLevel(SSP2_ID))
;
GPIO_WritePinOutput(EPD_DC, GPIO_IO_HIGH);
for (uint16_t i = 0; i < len; i++) {
SSP_SendData(SSP2_ID, buffer[i]);
while (SSP_GetTxFifoLevel(SSP2_ID) > 8)
;
}
while (SSP_GetTxFifoLevel(SSP2_ID))
;
delay_us(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
enableHardSPI(false);
}
void epdBlockWrite(uint8_t *buffer, uint16_t len) {
enableHardSPI(true);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_LOW);
GPIO_WritePinOutput(EPD_DC, GPIO_IO_HIGH);
for (uint16_t i = 0; i < len; i++) {
SSP_SendData(SSP2_ID, buffer[i]);
while (SSP_GetTxFifoLevel(SSP2_ID) > 8)
;
}
while (SSP_GetTxFifoLevel(SSP2_ID))
;
delay_us(1);
GPIO_WritePinOutput(EPD_CS, GPIO_IO_HIGH);
enableHardSPI(false);
}

View File

@@ -0,0 +1,68 @@
#pragma once
// #include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
class epdInterface {
public:
virtual ~epdInterface() = 0;
virtual void epdSetup() = 0;
virtual void epdEnterSleep() = 0;
virtual void draw() = 0;
virtual void drawNoWait() = 0;
virtual void epdWaitRdy() = 0;
virtual void selectLUT(uint8_t lut) = 0;
uint8_t controllerType = 0;
uint16_t Xres;
uint16_t Yres;
uint16_t effectiveXRes;
uint16_t effectiveYRes;
uint16_t XOffset = 0;
uint16_t YOffset = 0;
uint8_t bpp = 0;
bool drawDirectionRight = false;
bool epdMirrorV = false;
bool epdMirrorH = false;
};
struct tagSpecs {
uint8_t buttonCount = 0;
bool hasNFC = false;
bool hasLED = false;
uint16_t macSuffix = 0x0000;
uint8_t OEPLtype = 0;
uint8_t solumType = 0;
uint32_t imageSize = 0;
} __attribute__((packed));
extern __attribute__((section(".aonshadow"))) tagSpecs tag;
//__attribute__((section(".aonshadow")))
extern epdInterface *epd;
void epdSetup();
void epdEnterSleep();
void draw();
void drawNoWait();
void drawWithSleep();
void epdWaitRdy();
#define EPD_LUT_DEFAULT 0
#define EPD_LUT_NO_REPEATS 1
#define EPD_LUT_FAST_NO_REDS 2
#define EPD_LUT_FAST 3
void selectLUT(uint8_t lut);
void initEPDGPIO();
void busyWaitUntil(bool high, uint32_t timeout);
void softSPIWriteByte(char byteOut);
uint8_t softSPIReadByte();
void enableHardSPI(bool enable);
void epdWrite(uint8_t reg, uint8_t len, ...);
void epdBlockWrite(uint8_t reg, uint8_t *buffer, uint16_t len);
void epdBlockWrite(uint8_t *buffer, uint16_t len);

View File

@@ -1,260 +0,0 @@
#pragma once
#include <stdint.h>
static const uint8_t font[256][20]={ // https://raw.githubusercontent.com/basti79/LCD-fonts/master/10x16_vertikal_MSB_1.h
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00
{0xE0,0x01,0x30,0x03,0x50,0x02,0x28,0x05,0x28,0x04,0x28,0x04,0x28,0x05,0x50,0x02,0x30,0x03,0xE0,0x01}, // 0x01
{0xE0,0x01,0xF0,0x03,0xB0,0x03,0xD8,0x06,0xD8,0x07,0xD8,0x07,0xD8,0x06,0xB0,0x03,0xF0,0x03,0xE0,0x01}, // 0x02
{0x00,0x3E,0x80,0x7F,0xE0,0x7F,0xF0,0x7F,0xF8,0x3F,0xF8,0x3F,0xF0,0x7F,0xE0,0x7F,0x80,0x7F,0x00,0x3E}, // 0x03
{0x00,0x01,0x80,0x03,0xC0,0x0F,0xE0,0x1F,0xF8,0x7F,0xF0,0x1F,0xE0,0x0F,0xC0,0x07,0x80,0x03,0x00,0x01}, // 0x04
{0x80,0x03,0xC0,0x07,0xC0,0x07,0xC0,0x3F,0xF8,0x7F,0xB8,0x7F,0xC0,0x3F,0xC0,0x07,0xC0,0x07,0x80,0x03}, // 0x05
{0x80,0x03,0xC0,0x07,0xC0,0x0F,0xC0,0x1F,0xF8,0x3F,0xB8,0x7F,0xC0,0x1F,0xC0,0x0F,0xC0,0x07,0x80,0x03}, // 0x06
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A
{0xE0,0x01,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x24,0x10,0x2E,0xE0,0x71,0x00,0x70,0x00,0x18}, // 0x0B
{0x00,0x00,0x00,0x1E,0x20,0x21,0xA0,0x40,0xF8,0x40,0xA0,0x40,0xA0,0x41,0x00,0x21,0x00,0x1E,0x00,0x00}, // 0x0C
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D
{0x06,0x00,0x0E,0x00,0x0E,0x00,0xFC,0x1F,0x00,0x18,0x30,0x10,0x70,0x30,0x70,0x20,0xE0,0x7F,0x00,0x00}, // 0x0E
{0x00,0x01,0xC0,0x0F,0xC0,0x04,0x40,0x08,0x60,0x18,0x40,0x08,0x40,0x04,0xC0,0x0C,0xC0,0x0B,0x00,0x01}, // 0x0F
{0xF8,0x0F,0xF0,0x07,0xF0,0x07,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xC0,0x01,0xC0,0x01,0x80,0x00,0x80,0x00}, // 0x10
{0x80,0x00,0x80,0x00,0xC0,0x01,0xC0,0x01,0xE0,0x03,0xE0,0x03,0xE0,0x03,0xF0,0x07,0xF0,0x07,0xF8,0x0F}, // 0x11
{0x00,0x00,0x00,0x00,0x08,0x10,0x04,0x20,0xFE,0x7F,0x04,0x20,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x12
{0x00,0x00,0x00,0x00,0xD8,0x7F,0x00,0x00,0x00,0x00,0xD8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x13
{0x00,0x00,0x00,0x38,0x00,0x7C,0x00,0x7E,0xFE,0x7F,0x00,0x40,0x00,0x40,0xFE,0x7F,0x00,0x00,0x00,0x00}, // 0x14
{0x00,0x00,0x00,0x00,0x86,0x3B,0xC2,0x4C,0x42,0x44,0x62,0x46,0x32,0x42,0xDC,0x41,0x00,0x00,0x00,0x00}, // 0x15
{0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00}, // 0x16
{0x00,0x00,0x00,0x00,0x11,0x10,0x09,0x20,0xFD,0x7F,0x09,0x20,0x11,0x10,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x17
{0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x20,0xFE,0x7F,0x00,0x20,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x18
{0x00,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0xFE,0x7F,0x04,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x19
{0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x02,0xC0,0x01,0x80,0x00,0x00,0x00}, // 0x1A
{0x00,0x00,0x80,0x00,0xC0,0x01,0xA0,0x02,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x00}, // 0x1B
{0x00,0x00,0xF8,0x07,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00}, // 0x1C
{0x00,0x00,0x80,0x00,0xC0,0x01,0xA0,0x02,0x80,0x00,0x80,0x00,0xA0,0x02,0xC0,0x01,0x80,0x00,0x00,0x00}, // 0x1D
{0x08,0x00,0x18,0x00,0x78,0x00,0xF8,0x01,0xF8,0x03,0xF8,0x0F,0xF8,0x03,0xF8,0x00,0x38,0x00,0x08,0x00}, // 0x1E
{0x00,0x08,0x00,0x0C,0x00,0x0F,0xC0,0x0F,0xE0,0x0F,0xF8,0x0F,0xE0,0x0F,0x80,0x0F,0x00,0x0E,0x00,0x08}, // 0x1F
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x21
{0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x22
{0x80,0x00,0x98,0x04,0xE0,0x05,0x80,0x1E,0x98,0x64,0xE0,0x05,0x80,0x1E,0x80,0x64,0x80,0x04,0x00,0x00}, // 0x23
{0x00,0x00,0x00,0x00,0x18,0x38,0x08,0x64,0x08,0x42,0xFC,0xFF,0x88,0x41,0xF0,0x40,0x00,0x00,0x00,0x00}, // 0x24
{0x08,0x38,0x10,0x44,0x20,0x44,0xC0,0x44,0x00,0x39,0x70,0x02,0x88,0x0C,0x88,0x10,0x88,0x20,0x70,0x40}, // 0x25
{0xE0,0x00,0x10,0x01,0x08,0x3A,0x08,0x46,0x88,0x45,0xC8,0x4C,0x38,0x38,0x18,0x00,0x68,0x00,0x80,0x01}, // 0x26
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x27
{0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0x18,0x18,0x0C,0x30,0x04,0x20,0x02,0x40,0x02,0x40,0x00,0x00}, // 0x28
{0x00,0x00,0x02,0x40,0x02,0x40,0x04,0x20,0x0C,0x30,0x18,0x18,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x29
{0x00,0x00,0x00,0x10,0x00,0x18,0x00,0x0F,0x00,0x72,0x00,0x0F,0x00,0x18,0x00,0x10,0x00,0x00,0x00,0x00}, // 0x2A
{0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0xF8,0x07,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,0x00}, // 0x2B
{0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2C
{0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x00,0x00,0x00}, // 0x2D
{0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x2E
{0x00,0x00,0x02,0x00,0x0C,0x00,0x30,0x00,0xC0,0x00,0x00,0x03,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x00}, // 0x2F
{0x00,0x00,0xC0,0x0F,0x30,0x30,0x08,0x40,0x08,0x40,0x08,0x40,0x30,0x30,0xC0,0x0F,0x00,0x00,0x00,0x00}, // 0x30
{0x00,0x00,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x7F,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x31
{0x00,0x00,0x18,0x60,0x28,0x40,0x48,0x40,0x88,0x40,0x08,0x43,0x08,0x3C,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x32
{0x00,0x00,0x00,0x00,0x08,0x40,0x08,0x42,0x08,0x42,0x08,0x42,0xF0,0x3D,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x33
{0xC0,0x00,0x40,0x03,0x40,0x04,0x40,0x18,0x40,0x20,0xF8,0x7F,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00}, // 0x34
{0x00,0x00,0x00,0x00,0x08,0x7C,0x08,0x44,0x08,0x44,0x10,0x42,0xE0,0x41,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x35
{0x00,0x00,0xE0,0x0F,0x10,0x32,0x08,0x44,0x08,0x44,0x08,0x44,0x10,0x42,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0x36
{0x00,0x00,0x00,0x40,0x18,0x40,0xE0,0x40,0x00,0x43,0x00,0x4C,0x00,0x50,0x00,0x60,0x00,0x00,0x00,0x00}, // 0x37
{0x00,0x00,0xF0,0x38,0x08,0x45,0x08,0x42,0x08,0x42,0x08,0x45,0x90,0x45,0x60,0x38,0x00,0x00,0x00,0x00}, // 0x38
{0x00,0x00,0x00,0x1E,0x08,0x21,0x88,0x40,0x88,0x40,0x88,0x40,0x30,0x21,0xC0,0x1F,0x00,0x00,0x00,0x00}, // 0x39
{0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x06,0x18,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x3A
{0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x06,0x1E,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x3B
{0x00,0x00,0x00,0x00,0xC0,0x00,0xC0,0x00,0x20,0x01,0x20,0x01,0x10,0x02,0x10,0x02,0x08,0x04,0x00,0x00}, // 0x3C
{0x00,0x00,0x20,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x20,0x01,0x00,0x00}, // 0x3D
{0x00,0x00,0x08,0x04,0x10,0x02,0x10,0x02,0x20,0x01,0x20,0x01,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00}, // 0x3E
{0x00,0x00,0x00,0x70,0x00,0x40,0xD8,0x40,0x00,0x41,0x00,0x42,0x00,0x64,0x00,0x38,0x00,0x00,0x00,0x00}, // 0x3F
{0xC0,0x0F,0x30,0x18,0x18,0x20,0xC8,0x47,0x28,0x48,0x68,0x50,0xD8,0x51,0xE0,0x3F,0x20,0x00,0x20,0x00}, // 0x40
{0x08,0x00,0x70,0x00,0xC0,0x01,0x40,0x0E,0x40,0x18,0x40,0x0C,0x40,0x03,0xC0,0x00,0x30,0x00,0x08,0x00}, // 0x41
{0x00,0x00,0xF8,0x1F,0x08,0x11,0x08,0x11,0x08,0x11,0x08,0x11,0x88,0x12,0x70,0x0C,0x00,0x00,0x00,0x00}, // 0x42
{0xC0,0x03,0x30,0x0C,0x10,0x08,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x18,0x00,0x00,0x00,0x00}, // 0x43
{0x00,0x00,0xF8,0x1F,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x10,0x08,0xE0,0x07,0x00,0x00,0x00,0x00}, // 0x44
{0x00,0x00,0xF8,0x1F,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x08,0x10,0x00,0x00,0x00,0x00}, // 0x45
{0x00,0x00,0xF8,0x1F,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x00,0x10,0x00,0x00,0x00,0x00}, // 0x46
{0x00,0x00,0xC0,0x03,0x30,0x0C,0x10,0x08,0x08,0x10,0x08,0x10,0x88,0x10,0x88,0x10,0xF8,0x18,0x00,0x00}, // 0x47
{0x00,0x00,0xF8,0x1F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xF8,0x1F,0x00,0x00,0x00,0x00}, // 0x48
{0x00,0x00,0x08,0x10,0x08,0x10,0x08,0x10,0xF8,0x1F,0x08,0x10,0x08,0x10,0x08,0x10,0x00,0x00,0x00,0x00}, // 0x49
{0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x10,0x08,0x10,0x08,0x10,0xF0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x4A
{0x00,0x00,0xF8,0x1F,0x00,0x01,0x80,0x01,0x40,0x02,0x20,0x04,0x20,0x08,0x10,0x10,0x08,0x00,0x00,0x00}, // 0x4B
{0x00,0x00,0xF8,0x1F,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x4C
{0xF8,0x1F,0x00,0x1C,0x80,0x07,0xE0,0x00,0x60,0x00,0x80,0x03,0x00,0x1C,0xF8,0x1F,0x00,0x00,0x00,0x00}, // 0x4D
{0x00,0x00,0xF8,0x1F,0x00,0x08,0x00,0x06,0x80,0x01,0x60,0x00,0x10,0x00,0xF8,0x1F,0x00,0x00,0x00,0x00}, // 0x4E
{0x00,0x00,0xE0,0x07,0x10,0x08,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x10,0x08,0xE0,0x07,0x00,0x00}, // 0x4F
{0x00,0x00,0xF8,0x1F,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x00,0x11,0x00,0x0E,0x00,0x00,0x00,0x00}, // 0x50
{0x00,0x00,0xE0,0x07,0x10,0x08,0x08,0x10,0x08,0x10,0x08,0x10,0x0C,0x10,0x12,0x08,0xE2,0x07,0x00,0x00}, // 0x51
{0x00,0x00,0xF8,0x1F,0x80,0x10,0x80,0x10,0xC0,0x10,0x20,0x11,0x10,0x0E,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x52
{0x00,0x00,0x18,0x0E,0x08,0x12,0x08,0x11,0x08,0x11,0x88,0x10,0x90,0x10,0x70,0x18,0x00,0x00,0x00,0x00}, // 0x53
{0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xF8,0x1F,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00}, // 0x54
{0x00,0x00,0xE0,0x1F,0x18,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0xE0,0x1F,0x00,0x00,0x00,0x00}, // 0x55
{0x00,0x10,0x00,0x0C,0x80,0x03,0x60,0x00,0x18,0x00,0x18,0x00,0xE0,0x00,0x00,0x03,0x00,0x0C,0x00,0x10}, // 0x56
{0x00,0x18,0xC0,0x07,0x38,0x00,0xF0,0x00,0x00,0x07,0x80,0x03,0x70,0x00,0x38,0x00,0xC0,0x07,0x00,0x18}, // 0x57
{0x08,0x10,0x10,0x08,0x20,0x04,0x40,0x02,0x80,0x01,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08,0x08,0x10}, // 0x58
{0x00,0x10,0x00,0x08,0x00,0x06,0x00,0x01,0xF8,0x00,0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10}, // 0x59
{0x00,0x00,0x18,0x10,0x28,0x10,0x48,0x10,0x88,0x10,0x08,0x11,0x08,0x12,0x08,0x14,0x08,0x18,0x00,0x00}, // 0x5A
{0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x00,0x00,0x00,0x00}, // 0x5B
{0x00,0x00,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x03,0xC0,0x00,0x30,0x00,0x0C,0x00,0x02,0x00,0x00,0x00}, // 0x5C
{0x00,0x00,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0xFE,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x5D
{0x00,0x00,0x20,0x00,0xC0,0x00,0x00,0x07,0x00,0x1C,0x00,0x70,0x00,0x0E,0xC0,0x01,0x20,0x00,0x00,0x00}, // 0x5E
{0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00}, // 0x5F
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x60
{0x00,0x00,0x30,0x00,0x48,0x04,0x88,0x04,0x88,0x04,0x90,0x04,0xF8,0x03,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x61
{0x00,0x00,0xF8,0x7F,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x10,0x06,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0x62
{0x00,0x00,0xE0,0x01,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x00,0x00,0x00,0x00}, // 0x63
{0x00,0x00,0xE0,0x01,0x18,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x10,0x02,0xF8,0x7F,0x00,0x00,0x00,0x00}, // 0x64
{0x00,0x00,0xE0,0x01,0x90,0x02,0x88,0x04,0x88,0x04,0x88,0x04,0x88,0x04,0x88,0x03,0x00,0x00,0x00,0x00}, // 0x65
{0x00,0x00,0x00,0x04,0x00,0x04,0xF8,0x3F,0x00,0x24,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x00}, // 0x66
{0x00,0x00,0xE0,0x01,0x19,0x02,0x09,0x04,0x09,0x04,0x09,0x04,0x12,0x02,0xFC,0x07,0x00,0x00,0x00,0x00}, // 0x67
{0x00,0x00,0xF8,0x7F,0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x04,0xF8,0x03,0x00,0x00,0x00,0x00}, // 0x68
{0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x64,0xF8,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x69
{0x00,0x00,0x01,0x00,0x01,0x04,0x01,0x04,0x01,0x64,0xFE,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x6A
{0x00,0x00,0xF8,0x7F,0x80,0x00,0xC0,0x00,0x20,0x01,0x20,0x02,0x10,0x02,0x08,0x04,0x00,0x00,0x00,0x00}, // 0x6B
{0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0xF8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x6C
{0xF8,0x07,0x00,0x02,0x00,0x04,0x00,0x04,0xF8,0x03,0x00,0x02,0x00,0x04,0x00,0x04,0xF8,0x03,0x00,0x00}, // 0x6D
{0x00,0x00,0xF8,0x07,0x00,0x03,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x04,0xF8,0x03,0x00,0x00,0x00,0x00}, // 0x6E
{0x00,0x00,0xE0,0x01,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x10,0x02,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0x6F
{0x00,0x00,0xFF,0x07,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x10,0x06,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0x70
{0x00,0x00,0xE0,0x01,0x18,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x10,0x02,0xFF,0x07,0x00,0x00,0x00,0x00}, // 0x71
{0x00,0x00,0x00,0x00,0xF8,0x07,0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x07,0x00,0x00,0x00,0x00}, // 0x72
{0x00,0x00,0x18,0x03,0x88,0x04,0x88,0x04,0x48,0x04,0x48,0x04,0x30,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x73
{0x00,0x00,0x00,0x04,0x00,0x04,0xF0,0x1F,0x08,0x04,0x08,0x04,0x08,0x04,0x08,0x04,0x00,0x00,0x00,0x00}, // 0x74
{0x00,0x00,0xF0,0x07,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x75
{0x00,0x04,0x80,0x03,0x60,0x00,0x18,0x00,0x08,0x00,0x30,0x00,0xC0,0x00,0x00,0x03,0x00,0x04,0x00,0x00}, // 0x76
{0x00,0x06,0xE0,0x01,0x18,0x00,0x70,0x00,0x80,0x03,0x80,0x01,0x70,0x00,0x18,0x00,0xE0,0x01,0x00,0x06}, // 0x77
{0x00,0x00,0x08,0x04,0x10,0x02,0x20,0x01,0xC0,0x00,0xC0,0x00,0x20,0x01,0x10,0x02,0x08,0x04,0x00,0x00}, // 0x78
{0x01,0x04,0x01,0x03,0xC1,0x00,0x62,0x00,0x1C,0x00,0x18,0x00,0x60,0x00,0x80,0x00,0x00,0x03,0x00,0x04}, // 0x79
{0x00,0x00,0x08,0x04,0x18,0x04,0x28,0x04,0x48,0x04,0x88,0x04,0x08,0x05,0x08,0x06,0x08,0x04,0x00,0x00}, // 0x7A
{0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x7C,0x3F,0x02,0x40,0x02,0x40,0x02,0x40,0x00,0x00,0x00,0x00}, // 0x7B
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x7C
{0x00,0x00,0x00,0x00,0x02,0x40,0x02,0x40,0x02,0x40,0x7C,0x3F,0x80,0x00,0x80,0x00,0x00,0x00,0x00,0x00}, // 0x7D
{0xC0,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x80,0x01}, // 0x7E
{0x00,0x00,0xF8,0x01,0x08,0x03,0x08,0x04,0x08,0x08,0x08,0x04,0x08,0x03,0xF8,0x01,0x00,0x00,0x00,0x00}, // 0x7F
{0xC0,0x03,0x30,0x0C,0x10,0x08,0x08,0x10,0x08,0x10,0x09,0x10,0x0D,0x10,0x0B,0x18,0x00,0x00,0x00,0x00}, // 0x80
{0x00,0x00,0xF0,0x07,0x08,0x20,0x08,0x00,0x08,0x00,0x10,0x20,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x81
{0x00,0x00,0xE0,0x01,0x90,0x02,0x88,0x04,0x88,0x24,0x88,0x44,0x88,0x04,0x88,0x03,0x00,0x00,0x00,0x00}, // 0x82
{0x00,0x00,0x30,0x00,0x48,0x24,0x88,0x44,0x88,0x44,0x90,0x24,0xF8,0x03,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x83
{0x00,0x00,0x30,0x00,0x48,0x24,0x88,0x04,0x88,0x04,0x90,0x24,0xF8,0x03,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x84
{0x00,0x00,0x30,0x00,0x48,0x44,0x88,0x24,0x88,0x04,0x90,0x04,0xF8,0x03,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x85
{0x00,0x00,0x30,0x00,0x48,0x04,0x88,0x44,0x88,0xA4,0x90,0x44,0xF8,0x03,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x86
{0x00,0x00,0xE0,0x01,0x10,0x02,0x08,0x04,0x09,0x04,0x0D,0x04,0x0B,0x04,0x08,0x04,0x00,0x00,0x00,0x00}, // 0x87
{0x00,0x00,0xE0,0x01,0x90,0x22,0x88,0x44,0x88,0x44,0x88,0x24,0x88,0x04,0x88,0x03,0x00,0x00,0x00,0x00}, // 0x88
{0x00,0x00,0xE0,0x01,0x90,0x02,0x88,0x24,0x88,0x04,0x88,0x04,0x88,0x24,0x88,0x03,0x00,0x00,0x00,0x00}, // 0x89
{0x00,0x00,0xE0,0x01,0x90,0x02,0x88,0x44,0x88,0x24,0x88,0x04,0x88,0x04,0x88,0x03,0x00,0x00,0x00,0x00}, // 0x8A
{0x00,0x00,0x00,0x04,0x00,0x24,0x00,0x04,0xF8,0x07,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x8B
{0x00,0x00,0x00,0x04,0x00,0x24,0x00,0x44,0xF8,0x47,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x8C
{0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x44,0xF8,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x8D
{0x08,0x00,0x70,0x00,0xC0,0x81,0x40,0x0E,0x40,0x18,0x40,0x0C,0x40,0x83,0xC0,0x00,0x30,0x00,0x08,0x00}, // 0x8E
{0x08,0x00,0x70,0x00,0xC0,0x01,0x40,0x4E,0x40,0xB0,0x40,0xB8,0x40,0x4F,0xC0,0x01,0x70,0x00,0x08,0x00}, // 0x8F
{0x00,0x00,0xF8,0x1F,0x88,0x10,0x88,0x10,0x88,0x50,0x88,0x90,0x88,0x10,0x08,0x10,0x00,0x00,0x00,0x00}, // 0x90
{0x70,0x04,0xC8,0x04,0x88,0x04,0x88,0x04,0xF0,0x03,0x98,0x04,0x88,0x04,0x88,0x04,0x88,0x03,0x00,0x00}, // 0x91
{0x08,0x00,0x30,0x00,0xE0,0x01,0x20,0x06,0x20,0x18,0xF8,0x1F,0x88,0x10,0x88,0x10,0x08,0x10,0x00,0x00}, // 0x92
{0x00,0x00,0xE0,0x01,0x10,0x22,0x08,0x44,0x08,0x44,0x08,0x24,0x10,0x02,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0x93
{0x00,0x00,0xE0,0x01,0x10,0x22,0x08,0x04,0x08,0x04,0x08,0x24,0x10,0x02,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0x94
{0x00,0x00,0xE0,0x01,0x10,0x42,0x08,0x24,0x08,0x04,0x08,0x04,0x10,0x02,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0x95
{0x00,0x00,0xF0,0x07,0x08,0x20,0x08,0x40,0x08,0x40,0x10,0x20,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x96
{0x00,0x00,0xF0,0x07,0x08,0x40,0x08,0x20,0x08,0x00,0x10,0x00,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x97
{0x01,0x04,0x01,0x03,0xC1,0x20,0x62,0x00,0x1C,0x00,0x18,0x20,0x60,0x00,0x80,0x00,0x00,0x03,0x00,0x04}, // 0x98
{0x00,0x00,0xE0,0x07,0x10,0x88,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x90,0x10,0x08,0xE0,0x07,0x00,0x00}, // 0x99
{0x00,0x00,0xE0,0x1F,0x18,0x80,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x80,0xE0,0x1F,0x00,0x00,0x00,0x00}, // 0x9A
{0x00,0x00,0xE8,0x01,0x10,0x02,0x28,0x04,0xC8,0x04,0x08,0x05,0x10,0x02,0xE0,0x05,0x00,0x00,0x00,0x00}, // 0x9B
{0x00,0x00,0x00,0x00,0x08,0x00,0x18,0x02,0xE8,0x3F,0x08,0x42,0x08,0x42,0x08,0x40,0x00,0x00,0x00,0x00}, // 0x9C
{0x00,0x00,0xE8,0x07,0x30,0x08,0x68,0x10,0x88,0x10,0x08,0x11,0x08,0x16,0x10,0x0C,0xE0,0x17,0x00,0x00}, // 0x9D
{0x00,0x00,0x08,0x04,0x10,0x02,0x20,0x01,0xC0,0x00,0xC0,0x00,0x20,0x01,0x10,0x02,0x08,0x04,0x00,0x00}, // 0x9E
{0x00,0x00,0x01,0x00,0x01,0x04,0x01,0x04,0xFE,0x7F,0x00,0x84,0x00,0x84,0x00,0x80,0x00,0x00,0x00,0x00}, // 0x9F
{0x00,0x00,0x30,0x00,0x48,0x04,0x88,0x04,0x88,0x24,0x90,0x44,0xF8,0x03,0x08,0x00,0x00,0x00,0x00,0x00}, // 0xA0
{0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0xF8,0x27,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xA1
{0x00,0x00,0xE0,0x01,0x10,0x02,0x08,0x04,0x08,0x24,0x08,0x44,0x10,0x02,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0xA2
{0x00,0x00,0xF0,0x07,0x08,0x00,0x08,0x00,0x08,0x20,0x10,0x40,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xA3
{0x00,0x00,0xF8,0x07,0x00,0x23,0x00,0x42,0x00,0x24,0x00,0x24,0x00,0x44,0xF8,0x03,0x00,0x00,0x00,0x00}, // 0xA4
{0x00,0x00,0xF8,0x1F,0x00,0x48,0x00,0x86,0x80,0xC1,0x60,0x40,0x10,0x80,0xF8,0x1F,0x00,0x00,0x00,0x00}, // 0xA5
{0x00,0x00,0x00,0x00,0x00,0x4C,0x00,0x52,0x00,0x52,0x00,0x52,0x00,0x3E,0x00,0x02,0x00,0x00,0x00,0x00}, // 0xA6
{0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x3C,0x00,0x00,0x00,0x00}, // 0xA7
{0x00,0x00,0x0E,0x00,0x13,0x00,0x11,0x00,0x21,0x00,0xC1,0x06,0x01,0x00,0x07,0x00,0x00,0x00,0x00,0x00}, // 0xA8
{0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x5D,0x00,0x55,0x00,0x5D,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00}, // 0xA9
{0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0xE0,0x01,0x00,0x00}, // 0xAA
{0x08,0x40,0x30,0x7E,0x40,0x00,0x80,0x01,0x00,0x06,0x00,0x08,0x08,0x31,0x38,0x41,0x28,0x01,0xC8,0x00}, // 0xAB
{0x08,0x40,0x30,0x7E,0x40,0x00,0x80,0x01,0x00,0x06,0x60,0x08,0xA0,0x30,0x20,0x41,0xF8,0x01,0x20,0x00}, // 0xAC
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xAD
{0x00,0x00,0x80,0x00,0x40,0x01,0x20,0x02,0x10,0x04,0x80,0x00,0x40,0x01,0x20,0x02,0x10,0x04,0x00,0x00}, // 0xAE
{0x00,0x00,0x10,0x04,0x20,0x02,0x40,0x01,0x80,0x00,0x10,0x04,0x20,0x02,0x40,0x01,0x80,0x00,0x00,0x00}, // 0xAF
{0x36,0xDB,0x36,0xDB,0x00,0x00,0x36,0xDB,0x36,0xDB,0x00,0x00,0x36,0xDB,0x36,0xDB,0x00,0x00,0x00,0x00}, // 0xB0
{0xDB,0x36,0xDB,0x36,0x36,0xDB,0xFF,0xFF,0xDB,0x36,0x36,0xDB,0xFF,0xFF,0xDB,0x36,0x36,0xDB,0x36,0xDB}, // 0xB1
{0xFF,0xFF,0xFF,0xFF,0x36,0xDB,0xFF,0xFF,0xFF,0xFF,0x36,0xDB,0xFF,0xFF,0xFF,0xFF,0x36,0xDB,0x36,0xDB}, // 0xB2
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xB3
{0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xB4
{0x08,0x00,0x70,0x00,0xC0,0x01,0x40,0x0E,0x40,0x58,0x40,0x8C,0x40,0x03,0xC0,0x00,0x30,0x00,0x08,0x00}, // 0xB5
{0x08,0x00,0x70,0x00,0xC0,0x01,0x40,0x4E,0x40,0x98,0x40,0x8C,0x40,0x43,0xC0,0x00,0x30,0x00,0x08,0x00}, // 0xB6
{0x08,0x00,0x70,0x00,0xC0,0x01,0x40,0x8E,0x40,0x58,0x40,0x0C,0x40,0x03,0xC0,0x00,0x30,0x00,0x08,0x00}, // 0xB7
{0xC0,0x0F,0x30,0x30,0x98,0x67,0xC8,0x4C,0x48,0x48,0x48,0x48,0x58,0x68,0x30,0x30,0xC0,0x0F,0x00,0x00}, // 0xB8
{0x40,0x01,0x40,0x01,0x40,0x01,0x7F,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xB9
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xBA
{0x40,0x01,0x40,0x01,0x40,0x01,0x7F,0x01,0x00,0x01,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xBB
{0x40,0x01,0x40,0x01,0x40,0x01,0x40,0xFF,0x40,0x00,0xC0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xBC
{0x00,0x00,0xC0,0x0F,0x20,0x10,0x30,0x20,0x10,0x20,0xF8,0x7F,0x10,0x20,0x10,0x20,0x00,0x00,0x00,0x00}, // 0xBD
{0x00,0x40,0x00,0x20,0x20,0x19,0x20,0x05,0xF8,0x03,0x20,0x05,0x20,0x09,0x00,0x10,0x00,0x20,0x00,0x40}, // 0xBE
{0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xBF
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00}, // 0xC0
{0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0xFF,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00}, // 0xC1
{0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00}, // 0xC2
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00}, // 0xC3
{0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00}, // 0xC4
{0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0xFF,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00}, // 0xC5
{0x00,0x00,0x30,0x00,0x48,0x24,0x88,0x44,0x88,0x24,0x90,0x24,0xF8,0x43,0x08,0x00,0x00,0x00,0x00,0x00}, // 0xC6
{0x08,0x00,0x70,0x00,0xC0,0x41,0x40,0x8E,0x40,0xD8,0x40,0x4C,0x40,0x83,0xC0,0x00,0x30,0x00,0x08,0x00}, // 0xC7
{0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0x40,0x00,0x40,0xFF,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01}, // 0xC8
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x01,0x00,0x01,0x7F,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01}, // 0xC9
{0x40,0x01,0x40,0x01,0x40,0x01,0x40,0xFF,0x40,0x00,0x40,0xFF,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01}, // 0xCA
{0x40,0x01,0x40,0x01,0x40,0x01,0x7F,0x01,0x00,0x01,0x7F,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01}, // 0xCB
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x7F,0xFF,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01}, // 0xCC
{0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01}, // 0xCD
{0x40,0x01,0x40,0x01,0x40,0x01,0x7F,0xFF,0x00,0x00,0x7F,0xFF,0x40,0x01,0x40,0x01,0x40,0x01,0x40,0x01}, // 0xCE
{0x00,0x00,0x20,0x10,0xC0,0x0F,0x40,0x08,0x40,0x08,0x40,0x08,0x40,0x08,0xC0,0x0F,0x20,0x10,0x00,0x00}, // 0xCF
{0x00,0x00,0xE0,0x41,0x10,0x52,0x08,0x74,0x08,0x24,0x08,0x54,0x10,0x0E,0xE0,0x03,0x00,0x00,0x00,0x00}, // 0xD0
{0x00,0x01,0xF8,0x1F,0x08,0x11,0x08,0x11,0x08,0x10,0x08,0x10,0x10,0x08,0xE0,0x07,0x00,0x00,0x00,0x00}, // 0xD1
{0x00,0x00,0xF8,0x1F,0x88,0x10,0x88,0x50,0x88,0x90,0x88,0x90,0x88,0x50,0x08,0x10,0x00,0x00,0x00,0x00}, // 0xD2
{0x00,0x00,0xF8,0x1F,0x88,0x90,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x90,0x08,0x10,0x00,0x00,0x00,0x00}, // 0xD3
{0x00,0x00,0xF8,0x1F,0x88,0x10,0x88,0x10,0x88,0x90,0x88,0x50,0x88,0x10,0x08,0x10,0x00,0x00,0x00,0x00}, // 0xD4
{0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xD5
{0x00,0x00,0x08,0x10,0x08,0x10,0x08,0x10,0xF8,0x5F,0x08,0x90,0x08,0x10,0x08,0x10,0x00,0x00,0x00,0x00}, // 0xD6
{0x00,0x00,0x08,0x10,0x08,0x10,0x08,0x50,0xF8,0x9F,0x08,0x90,0x08,0x50,0x08,0x10,0x00,0x00,0x00,0x00}, // 0xD7
{0x00,0x00,0x08,0x10,0x08,0x90,0x08,0x10,0xF8,0x1F,0x08,0x10,0x08,0x90,0x08,0x10,0x00,0x00,0x00,0x00}, // 0xD8
{0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xD9
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00}, // 0xDA
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, // 0xDB
{0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00}, // 0xDC
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xDD
{0x00,0x00,0x08,0x10,0x08,0x10,0x08,0x90,0xF8,0x5F,0x08,0x10,0x08,0x10,0x08,0x10,0x00,0x00,0x00,0x00}, // 0xDE
{0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF}, // 0xDF
{0x00,0x00,0xE0,0x07,0x10,0x08,0x08,0x10,0x08,0x50,0x08,0x90,0x08,0x10,0x10,0x08,0xE0,0x07,0x00,0x00}, // 0xE0
{0x00,0x00,0xF8,0x3F,0x00,0x40,0x00,0x40,0x08,0x47,0x88,0x38,0x48,0x00,0x30,0x00,0x00,0x00,0x00,0x00}, // 0xE1
{0x00,0x00,0xE0,0x07,0x10,0x08,0x08,0x50,0x08,0x90,0x08,0x90,0x08,0x50,0x10,0x08,0xE0,0x07,0x00,0x00}, // 0xE2
{0x00,0x00,0xE0,0x07,0x10,0x08,0x08,0x90,0x08,0x50,0x08,0x10,0x08,0x10,0x10,0x08,0xE0,0x07,0x00,0x00}, // 0xE3
{0x00,0x00,0xE0,0x01,0x10,0x22,0x08,0x44,0x08,0x24,0x08,0x24,0x10,0x42,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0xE4
{0x00,0x00,0xE0,0x07,0x10,0x48,0x08,0x90,0x08,0xD0,0x08,0x50,0x08,0x90,0x10,0x08,0xE0,0x07,0x00,0x00}, // 0xE5
{0x00,0x00,0xFF,0x07,0x10,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0xF8,0x07,0x00,0x00,0x00,0x00}, // 0xE6
{0x00,0x00,0xFF,0x7F,0x10,0x02,0x08,0x04,0x08,0x04,0x08,0x04,0x10,0x06,0xE0,0x01,0x00,0x00,0x00,0x00}, // 0xE7
{0x00,0x00,0xF8,0x1F,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x40,0x04,0x80,0x03,0x00,0x00,0x00,0x00}, // 0xE8
{0x00,0x00,0xE0,0x1F,0x18,0x00,0x08,0x00,0x08,0x40,0x08,0x80,0x10,0x00,0xE0,0x1F,0x00,0x00,0x00,0x00}, // 0xE9
{0x00,0x00,0xE0,0x1F,0x18,0x00,0x08,0x40,0x08,0x80,0x08,0x80,0x10,0x40,0xE0,0x1F,0x00,0x00,0x00,0x00}, // 0xEA
{0x00,0x00,0xE0,0x1F,0x18,0x00,0x08,0x80,0x08,0x40,0x08,0x00,0x10,0x00,0xE0,0x1F,0x00,0x00,0x00,0x00}, // 0xEB
{0x01,0x04,0x01,0x03,0xC1,0x00,0x62,0x00,0x1C,0x20,0x18,0x40,0x60,0x00,0x80,0x00,0x00,0x03,0x00,0x04}, // 0xEC
{0x00,0x10,0x00,0x08,0x00,0x06,0x00,0x01,0xF8,0x40,0x00,0x81,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10}, // 0xED
{0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80}, // 0xEE
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEF
{0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x00,0x00,0x00}, // 0xF0
{0x00,0x00,0x08,0x01,0x08,0x01,0x08,0x01,0x08,0x01,0xC8,0x07,0x08,0x01,0x08,0x01,0x08,0x01,0x00,0x00}, // 0xF1
{0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00,0x05,0x00}, // 0xF2
{0x08,0x42,0x10,0x52,0x20,0x5A,0xC0,0x6C,0x00,0x01,0x60,0x02,0xA0,0x0C,0x20,0x11,0xF8,0x21,0x20,0x40}, // 0xF3
{0x00,0x00,0x00,0x38,0x00,0x7C,0x00,0x7E,0xFE,0x7F,0x00,0x40,0x00,0x40,0xFE,0x7F,0x00,0x00,0x00,0x00}, // 0xF4
{0x00,0x00,0x00,0x00,0x86,0x3B,0xC2,0x4C,0x42,0x44,0x62,0x46,0x32,0x42,0xDC,0x41,0x00,0x00,0x00,0x00}, // 0xF5
{0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x58,0x06,0x58,0x06,0x40,0x00,0x40,0x00,0x40,0x00,0x00,0x00}, // 0xF6
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x05,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF7
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x48,0x00,0x48,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF8
{0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF9
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFA
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFB
{0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x52,0x00,0x52,0x00,0x52,0x00,0x6C,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFC
{0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x46,0x00,0x4A,0x00,0x4A,0x00,0x32,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xFD
{0x00,0x00,0xF8,0x07,0xF8,0x07,0xF8,0x07,0xF8,0x07,0xF8,0x07,0xF8,0x07,0xF8,0x07,0xF8,0x07,0x00,0x00}, // 0xFE
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF
};

View File

@@ -1,43 +1,55 @@
#include "main.h" // #include "main.h"
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include "epd_interface.h"
#include "powermgt.h"
#include "main.h"
#include "settings.h"
extern "C" {
#include "comms.h" #include "comms.h"
#include "core_cm3.h" #include "mz100/core_cm3.h"
#include "eeprom.h" #include "mz100/eeprom.h"
#include "epd.h"
#include "gpio.h" #include "mz100/gpio.h"
#include "mz100.h" #include "mz100/mz100.h"
#include "mz100_aon_ram.h" #include "mz100/mz100_aon_ram.h"
#include "mz100_clock.h" #include "mz100/mz100_clock.h"
#include "mz100_flash.h" #include "mz100/mz100_flash.h"
#include "mz100_gpio.h" #include "mz100/mz100_gpio.h"
#include "mz100_pinmux.h" #include "mz100/mz100_pinmux.h"
#include "mz100_pmu.h" #include "mz100/mz100_pmu.h"
#include "mz100_sleep.h" #include "mz100/mz100_sleep.h"
#include "mz100_ssp.h" #include "mz100/mz100_ssp.h"
#include "mz100_uart.h" #include "mz100/mz100_uart.h"
#include "powermgt.h" #include "mz100/printf.h"
#include "printf.h"
#include "proto.h" #include "proto.h"
#include "settings.h"
#include "syncedproto.h" #include "mz100/timer.h"
#include "timer.h"
#include "userinterface.h" #include "mz100/util.h"
#include "util.h"
#include "zigbee.h" #include "zigbee.h"
extern void dump(const uint8_t *a, const uint16_t l);
}
#include "oepl-protocol.h"
#include "compression.h"
#include "userinterface.h"
#include "oepl_fs.h"
#define SW_VER_CURRENT (0x0000011300000000ull) // top 16 bits are off limits, xxxx.VV.tt.vvvv.mmmm means version V.t.v.m #define SW_VER_CURRENT (0x0000011300000000ull) // top 16 bits are off limits, xxxx.VV.tt.vvvv.mmmm means version V.t.v.m
#define SW_DEFAULT_MAC (0x0000000000000014ull) #define FW_MAGIC (0x14AFEEBCDC14AE5Aull)
uint64_t __attribute__((section(".ver"))) mCurVersionExport = SW_VER_CURRENT; uint64_t __attribute__((section(".ver"))) mCurVersionExport = SW_VER_CURRENT;
uint64_t __attribute__((section(".default_mac"))) default_mac = SW_DEFAULT_MAC; uint64_t __attribute__((section(".fwmagic"))) magic = FW_MAGIC;
char macStr[32];
char macStr1[32];
// uint8_t mSelfMac[8];
#define TAG_MODE_CHANSEARCH 0 #define TAG_MODE_CHANSEARCH 0
#define TAG_MODE_ASSOCIATED 1 #define TAG_MODE_ASSOCIATED 1
@@ -51,8 +63,8 @@ bool protectedFlashWrite(uint32_t address, uint8_t *buffer, uint32_t num) {
while (attempt--) { while (attempt--) {
qspiEraseRange(address, num); qspiEraseRange(address, num);
delay(50); delay(50);
FLASH_Write(false, address, buffer, num); FLASH_Write((FLASH_ProgramMode_Type) false, address, buffer, num);
FLASH_Read(0, address, buf2, num); FLASH_Read((FLASH_ReadMode_Type)0, address, buf2, num);
if (memcmp(buffer, buf2, num) == 0) { if (memcmp(buffer, buf2, num) == 0) {
printf("Flash block at %06X written successfully\n", address); printf("Flash block at %06X written successfully\n", address);
free(buf2); free(buf2);
@@ -65,17 +77,18 @@ bool protectedFlashWrite(uint32_t address, uint8_t *buffer, uint32_t num) {
return false; return false;
} }
static void prvGetSelfMac(void) { static void initTagProfile() {
FLASH_Read(0, EEPROM_MAC_INFO_START, mSelfMac, 8); for (uint8_t c = 0; c < 8; c++) {
mSelfMac[c] = tagProfile.macAddress[7 - c];
}
if ((((uint32_t *)mSelfMac)[0] | ((uint32_t *)mSelfMac)[1]) == 0 || (((uint32_t *)mSelfMac)[0] & ((uint32_t *)mSelfMac)[1]) == 0xffffffff) { // fastest way to check for all ones or all zeroes if ((((uint32_t *)mSelfMac)[0] | ((uint32_t *)mSelfMac)[1]) == 0 || (((uint32_t *)mSelfMac)[0] & ((uint32_t *)mSelfMac)[1]) == 0xffffffff) { // fastest way to check for all ones or all zeroes
printf("mac unknown\r\n"); printf("MAC: mac unknown, taking random Flash ID\n");
// Write a blank mac to have something to work with. *((uint64_t *)&tagProfile.macAddress) = FLASH_GetUniqueID();
memcpy(&mSelfMac, (uint8_t *)&default_mac, 8);
FLASH_Write(0, EEPROM_MAC_INFO_START, mSelfMac, 8);
// sleep_with_with_wakeup(0);
} }
tag.imageSize = flashRoundUp(sizeof(struct EepromImageHeader) + (tagProfile.xRes * tagProfile.yRes * tagProfile.bpp) / 8);
tag.OEPLtype = tagProfile.OEPLType;
} }
uint8_t showChannelSelect() { // returns 0 if no accesspoints were found uint8_t showChannelSelect() { // returns 0 if no accesspoints were found
@@ -88,7 +101,9 @@ uint8_t showChannelSelect() { // returns 0 if no accesspoints were found
if (detectAP(channelList[c])) { if (detectAP(channelList[c])) {
if (mLastLqi > result[c]) if (mLastLqi > result[c])
result[c] = mLastLqi; result[c] = mLastLqi;
printf("Channel: %d - LQI: %d RSSI %d\n", channelList[c], mLastLqi, mLastRSSI); #ifdef DEBUG_MAIN
printf("MAIN: Channel: %d - LQI: %d RSSI %d\n", channelList[c], mLastLqi, mLastRSSI);
#endif
} }
} }
} }
@@ -134,6 +149,7 @@ uint8_t channelSelect() { // returns 0 if no accesspoints were found
void __attribute__((interrupt)) NMIException(void) { void __attribute__((interrupt)) NMIException(void) {
printf("-----------> NMIException\r\n"); printf("-----------> NMIException\r\n");
delay(1000);
PMU->CLK_SRC.BF.MAIN_CLK_SOURCE = 1; PMU->CLK_SRC.BF.MAIN_CLK_SOURCE = 1;
PMU->PWR_MODE.BF.PWR_MODE = 0; PMU->PWR_MODE.BF.PWR_MODE = 0;
NVIC_SystemReset(); NVIC_SystemReset();
@@ -168,25 +184,42 @@ void __attribute__((interrupt)) UsageFaultException(void) {
} }
void __attribute__((interrupt)) SVCHandler(void) { void __attribute__((interrupt)) SVCHandler(void) {
printf("-----------> SVCHandler\r\n");
PMU->CLK_SRC.BF.MAIN_CLK_SOURCE = 1;
PMU->PWR_MODE.BF.PWR_MODE = 0;
NVIC_SystemReset();
} }
void __attribute__((interrupt)) DebugMonitor(void) { void __attribute__((interrupt)) DebugMonitor(void) {
printf("-----------> DebugMonitor\r\n");
PMU->CLK_SRC.BF.MAIN_CLK_SOURCE = 1;
PMU->PWR_MODE.BF.PWR_MODE = 0;
NVIC_SystemReset();
} }
void __attribute__((interrupt)) PendSVC(void) { void __attribute__((interrupt)) PendSVC(void) {
printf("-----------> PendSVC\r\n");
PMU->CLK_SRC.BF.MAIN_CLK_SOURCE = 1;
PMU->PWR_MODE.BF.PWR_MODE = 0;
NVIC_SystemReset();
} }
void setupRTC() { int32_t setupRTC(uint32_t calibrate) {
CLK_Xtal32MEnable(CLK_OSC_INTERN); // CLK_Xtal32MEnable(CLK_OSC_INTERN);
while (!CLK_GetClkStatus(CLK_OUT_XTAL64M)) // while (!CLK_GetClkStatus(CLK_OUT_XTAL64M))
; // ;
RC32K_CalClk_Div(63, 31); RC32K_CalClk_Div(63, 31);
CLK_ModuleClkEnable(CLK_RC32K_CAL); CLK_ModuleClkEnable(CLK_RC32K_CAL);
CLK_RC32KEnable(); CLK_RC32KEnable();
while (!CLK_GetClkStatus(CLK_OUT_RC32K)) while (!CLK_GetClkStatus(CLK_OUT_RC32K))
; ;
PMU->RC32K_CAL_CNTL.BF.RC32K_CAL_DIV = 0; PMU->RC32K_CAL_CNTL.BF.RC32K_CAL_DIV = 0;
CLK_RC32KCalibration(CLK_RC32KCAL_XTAL64M, CLK_AUTO_CAL, 0); int32_t calres;
if (!calibrate) {
calres = CLK_RC32KCalibration(CLK_RC32KCAL_XTAL64M, CLK_AUTO_CAL, 0);
} else {
calres = CLK_RC32KCalibration(CLK_RC32KCAL_XTAL64M, CLK_MANUAL_CAL, calibrate);
}
CLK_ModuleClkEnable(CLK_RTC); CLK_ModuleClkEnable(CLK_RTC);
CLK_RTCClkSrc(CLK_RTC_RC32K); CLK_RTCClkSrc(CLK_RTC_RC32K);
RTC_Stop(); RTC_Stop();
@@ -199,6 +232,7 @@ void setupRTC() {
NVIC_ClearPendingIRQ(RTC_IRQn); NVIC_ClearPendingIRQ(RTC_IRQn);
RTC_IntMask(RTC_INT_CNT_UPP, UNMASK); RTC_IntMask(RTC_INT_CNT_UPP, UNMASK);
NVIC_EnableIRQ(RTC_IRQn); NVIC_EnableIRQ(RTC_IRQn);
return calres;
} }
void setupUART() { void setupUART() {
@@ -210,41 +244,30 @@ void setupUART() {
UART_CFG_Type uartcfg; UART_CFG_Type uartcfg;
uartcfg.baudRate = 115200; uartcfg.baudRate = 115200;
uartcfg.dataBits = UART_DATABITS_8; uartcfg.dataBits = UART_DATABITS_8;
uartcfg.stopBits = 1; uartcfg.stopBits = (UART_StopBits_Type)1;
uartcfg.parity = UART_PARITY_NONE; uartcfg.parity = UART_PARITY_NONE;
uartcfg.autoFlowControl = DISABLE; uartcfg.autoFlowControl = DISABLE;
UART_Init(1, &uartcfg); UART_Init((UART_ID_Type)1, &uartcfg);
UART_FIFO_Type uartFifo; UART_FIFO_Type uartFifo;
uartFifo.FIFO_ResetRx = 1; uartFifo.FIFO_ResetRx = (FunctionalState)1;
uartFifo.FIFO_ResetTx = 1; uartFifo.FIFO_ResetTx = (FunctionalState)1;
uartFifo.FIFO_Function = 1; uartFifo.FIFO_Function = (FunctionalState)1;
uartFifo.FIFO_RcvrTrigger = 2; uartFifo.FIFO_RcvrTrigger = (UART_RxFIFOLevel_Type)2;
uartFifo.FIFO_TxEmptyTrigger = 3; uartFifo.FIFO_TxEmptyTrigger = (UART_TxFIFOLevel_Type)3;
UART_FIFOConfig(1, &uartFifo); UART_FIFOConfig((UART_ID_Type)1, &uartFifo);
// UART 1 DEBUG OUT // UART 1 DEBUG OUT
} }
void setupWDT() {
//** WATCHDOG
CLK_ModuleClkEnable(CLK_WDT);
WDT_SetMode(WDT_MODE_RESET);
WDT_SetResetPulseLen(WDT_RESET_PULSE_LEN_256);
WDT_SetTimeoutVal(30);
WDT_RestartCounter();
WDT_Enable();
//** WATCHDOG
}
void setupGPIO() { void setupGPIO() {
//** GPIOS //** GPIOS
init_GPIO_boot(); init_GPIO_boot();
// NFC POWER Should be on if NFC is wanted to be used // NFC POWER Should be on if NFC is wanted to be used
GPIO_PinOutputModeConfig(NFC_POWER, PIN_OUTPUT_MODE_NORMAL_FUNCTION); GPIO_PinOutputModeConfig(NFC_POWER, PIN_OUTPUT_MODE_NORMAL_FUNCTION);
GPIO_PinModeConfig(NFC_POWER, PINMODE_DEFAULT); GPIO_PinModeConfig(NFC_POWER, PINMODE_DEFAULT);
GPIO_PinMuxFun(NFC_POWER, 0); GPIO_PinMuxFun(NFC_POWER, (GPIO_PinMuxFunc_Type)0);
GPIO_SetPinDir(NFC_POWER, GPIO_OUTPUT); GPIO_SetPinDir(NFC_POWER, GPIO_OUTPUT);
GPIO_WritePinOutput(NFC_POWER, 1); // Better power NFC up so IRQ will work unpowered later GPIO_WritePinOutput(NFC_POWER, (GPIO_IO_Type)1); // Better power NFC up so IRQ will work unpowered later
//** GPIOS //** GPIOS
if (!(~(*(volatile unsigned int *)0x4A080000) << 30)) { if (!(~(*(volatile unsigned int *)0x4A080000) << 30)) {
NVIC_EnableIRQ(ExtPin5_IRQn); NVIC_EnableIRQ(ExtPin5_IRQn);
@@ -252,9 +275,9 @@ void setupGPIO() {
} }
} }
void setupCLKCalib() { int32_t setupCLKCalib() {
(*(volatile unsigned int *)0x4A070004) = ((*(volatile unsigned int *)0x4A070004) & 0xFFFFFFE0) + 2; (*(volatile unsigned int *)0x4A070004) = ((*(volatile unsigned int *)0x4A070004) & 0xFFFFFFE0) + 2;
PMU->PWR_MODE.BF.PWR_MODE = 2; // PMU->PWR_MODE.BF.PWR_MODE = 2; // hmmm
uint32_t v0 = FLASH_WordRead(FLASH_NORMAL_READ, 4u); uint32_t v0 = FLASH_WordRead(FLASH_NORMAL_READ, 4u);
char v1; char v1;
if (!(~v0 << 25)) { if (!(~v0 << 25)) {
@@ -263,6 +286,19 @@ void setupCLKCalib() {
; ;
v1 = CLK_RC32MCalibration(CLK_AUTO_CAL, 0); v1 = CLK_RC32MCalibration(CLK_AUTO_CAL, 0);
FLASH_WordWrite(FLASH_PROGRAM_NORMAL, 4u, (v0 & 0xFFFFFF00) | (v1 & 0x7F)); FLASH_WordWrite(FLASH_PROGRAM_NORMAL, 4u, (v0 & 0xFFFFFF00) | (v1 & 0x7F));
return v1;
}
return -1;
}
void checkWDT() {
uint32_t val1 = WDT_GetCounterVal();
delay(10000);
uint32_t val2 = WDT_GetCounterVal();
if (val1 == val2) {
printf("WDT: Not running!\n");
} else {
printf("WDT: 1: %lu 2: %lu divider is now %lu\n", val1, val2, (val2 - val1) / 10000);
} }
} }
@@ -282,22 +318,27 @@ void TagAssociated() {
// check if the battery level is below minimum, and force a redraw of the screen // check if the battery level is below minimum, and force a redraw of the screen
if ((lowBattery && !lowBatteryShown && tagSettings.enableLowBatSymbol) || (noAPShown && tagSettings.enableNoRFSymbol)) { if ((lowBattery && !lowBatteryShown && tagSettings.enableLowBatSymbol) ||
printf("For some reason, we're going to redraw the image. lowbat=%d, lowbatshown=%d, noAPShown=%d\n", lowBattery, lowBatteryShown, noAPShown); (!lowBattery && lowBatteryShown) ||
(noAPShown && tagSettings.enableNoRFSymbol)) {
// Check if we were already displaying an image // Check if we were already displaying an image
if (curImgSlot != 0xFF) { if (curImgSlot != 0xFF) {
powerUp(INIT_EEPROM | INIT_EPD); powerUp(INIT_EEPROM | INIT_EPD);
wdt60s(); wdt60s();
drawImageFromEeprom(curImgSlot); drawImageFromEeprom(curImgSlot, 0);
powerDown(INIT_EEPROM | INIT_EPD); powerDown(INIT_EEPROM | INIT_EPD);
} else { } else {
powerUp(INIT_EPD); wdt60s();
showAPFound(); showAPFound();
powerDown(INIT_EPD); wdt60s();
} }
} }
powerUp(INIT_RADIO); powerUp(INIT_RADIO);
#ifdef DEBUG_MAIN
printf("MAIN: full request\n");
#endif
avail = getAvailDataInfo();
avail = getAvailDataInfo(); avail = getAvailDataInfo();
powerDown(INIT_RADIO); powerDown(INIT_RADIO);
@@ -369,12 +410,13 @@ void TagChanSearch() {
// Check if we should redraw the screen with icons, info screen or screensaver // Check if we should redraw the screen with icons, info screen or screensaver
if ((!currentChannel && !noAPShown && tagSettings.enableNoRFSymbol) || if ((!currentChannel && !noAPShown && tagSettings.enableNoRFSymbol) ||
(lowBattery && !lowBatteryShown && tagSettings.enableLowBatSymbol) || (lowBattery && !lowBatteryShown && tagSettings.enableLowBatSymbol) ||
(!lowBattery && lowBatteryShown) ||
(scanAttempts == (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) { (scanAttempts == (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) {
powerUp(INIT_EPD); powerUp(INIT_EPD);
wdt60s(); wdt60s();
if (curImgSlot != 0xFF) { if (curImgSlot != 0xFF) {
powerUp(INIT_EEPROM); powerUp(INIT_EEPROM);
drawImageFromEeprom(curImgSlot); drawImageFromEeprom(curImgSlot, 0);
powerDown(INIT_EEPROM); powerDown(INIT_EEPROM);
} else if ((scanAttempts >= (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) { } else if ((scanAttempts >= (INTERVAL_1_ATTEMPTS + INTERVAL_2_ATTEMPTS - 1))) {
showLongTermSleep(); showLongTermSleep();
@@ -386,16 +428,19 @@ void TagChanSearch() {
// did we find a working channel? // did we find a working channel?
if (currentChannel) { if (currentChannel) {
#ifdef DEBUG_PROTO
printf("PROTO: Found a working channel from the TagChanSearch loop\n");
#endif
// now associated! set up and bail out of this loop. // now associated! set up and bail out of this loop.
scanAttempts = 0; scanAttempts = 0;
wakeUpReason = WAKEUP_REASON_NETWORK_SCAN; wakeUpReason = WAKEUP_REASON_NETWORK_SCAN;
initPowerSaving(INTERVAL_BASE); initPowerSaving(INTERVAL_BASE);
doSleep(getNextSleep() * 1000UL);
currentTagMode = TAG_MODE_ASSOCIATED; currentTagMode = TAG_MODE_ASSOCIATED;
sleep_with_with_wakeup(getNextSleep() * 1000UL);
return; return;
} else { } else {
// still not associated // still not associated
doSleep(getNextScanSleep(true) * 1000UL); sleep_with_with_wakeup(getNextScanSleep(true) * 1000UL);
} }
} }
@@ -404,62 +449,86 @@ int main(void) {
(*(volatile unsigned int *)0xE000ED08) = 0x20100000; // Vector table in RAM and offset 0x4000 (*(volatile unsigned int *)0xE000ED08) = 0x20100000; // Vector table in RAM and offset 0x4000
(*(volatile unsigned int *)0xE000E41A) = 0x40; // ?? (*(volatile unsigned int *)0xE000E41A) = 0x40; // ??
timerInit();
CLK_SystemClkInit(CLK_SYS_XTAL64M, CLK_SYS_64M); CLK_SystemClkInit(CLK_SYS_XTAL64M, CLK_SYS_64M);
CLK_Xtal32MEnable(CLK_OSC_INTERN); CLK_Xtal32MEnable(CLK_OSC_INTERN);
while (CLK_GetClkStatus(CLK_OUT_XTAL64M) != 1) while (CLK_GetClkStatus(CLK_OUT_XTAL64M) != 1)
; ;
setupUART();
setupCLKCalib();
if (!loadValidateAonRam() || PMU_GetLastResetCause()) { if (!loadValidateAonRam() || PMU_GetLastResetCause()) {
setupWDT(); // cold boot!
printf("BOOT: Cold boot!\n");
// calibrate the 32K RC oscillator (autocal), we'll store the result to flash later
uint32_t rtccal = setupRTC(0);
setupGPIO(); setupGPIO();
setupCLKCalib(); timerInit();
setupUART(); setupWDT();
printf("Rst reason: %i\r\n", PMU_GetLastResetCause());
printf("AON is not valid!\n");
setupRTC();
clearAonRam();
clearAonRam();
// all variables are set to 0 now. This might not be appropriate for all variables, such as:
curImgSlot = 0xFF;
// try to load settings
if (!loadSettings()) {
// if we couldn't load settings, we'll try to get it from the tagprofile file. Useful during development
fs->init();
if (!loadProfileFromFile((char *)"tagprofile.bin")) {
// whoops. Empty profile, that shouldn't really ever happen, ever.
printf("We don't know the type of this tag. That's kinda bad, I guess...\n");
} else {
fs->deleteFile((char *)"tagprofile.bin");
}
} else {
printf("BOOT: Loaded tag settings from EEPROM\n");
}
printf("BOOT: MAC: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", tagProfile.macAddress[0], tagProfile.macAddress[1], tagProfile.macAddress[2], tagProfile.macAddress[3], tagProfile.macAddress[4], tagProfile.macAddress[5], tagProfile.macAddress[6], tagProfile.macAddress[7]);
tagProfile.RC32Kcal = rtccal;
printf("BOOT: Rst reason: %i\r\n", PMU_GetLastResetCause());
initTagProfile();
wdt10s();
showSplashScreen(); showSplashScreen();
delay(10000);
currentChannel = 0; currentChannel = 0;
zigbeeCalibData.isValid = false; zigbeeCalibData.isValid = false;
wakeUpReason = WAKEUP_REASON_FIRSTBOOT; wakeUpReason = WAKEUP_REASON_FIRSTBOOT;
prvGetSelfMac();
initializeProto(); initializeProto();
printf("Erz data\r\n");
initPowerSaving(INTERVAL_BASE); initPowerSaving(INTERVAL_BASE);
loadDefaultSettings();
doVoltageReading(); doVoltageReading();
qspiEraseRange(EEPROM_SETTINGS_AREA_START, EEPROM_SETTINGS_AREA_LEN);
sprintf(macStr, "(" MACFMT ")", MACCVT(mSelfMac));
currentChannel = showChannelSelect(); currentChannel = showChannelSelect();
WDT_RestartCounter(); radioShutdown();
if (currentChannel) { if (currentChannel) {
printf("AP Found\r\n"); printf("BOOT: AP Found\n");
wdt10s();
delay(10000);
showAPFound(); showAPFound();
sprintf(macStr1, "OpenEPaperLink Ch: %i", currentChannel); wdt10s();
timerDelay(TIMER_TICKS_PER_MSEC * 1000); timerDelay(TIMER_TICKS_PER_MSEC * 1000);
currentTagMode = TAG_MODE_ASSOCIATED; currentTagMode = TAG_MODE_ASSOCIATED;
} else { } else {
printf("No AP found\r\n"); printf("BOOT: No AP found\n");
wdt10s();
delay(10000);
showNoAP(); showNoAP();
sleep_with_with_wakeup(120000UL); wdt10s();
timerDelay(TIMER_TICKS_PER_MSEC * 1000);
currentTagMode = TAG_MODE_CHANSEARCH; currentTagMode = TAG_MODE_CHANSEARCH;
} }
writeSettings();
printf("BOOT: Cold boot complete\n");
sleep_with_with_wakeup(5 * 1000UL);
} else { } else {
// setupWDT(); setupRTC(tagProfile.RC32Kcal);
setupWDT();
setupGPIO(); setupGPIO();
// setupCLKCalib(); timerInit();
// setupUART();
// setupRTC();
memset(curBlock.requestedParts, 0x00, BLOCK_REQ_PARTS_BYTES);
} }
powerUp(INIT_UART);
while (1) { while (1) {
wdt10s(); wdt10s();
switch (currentTagMode) { switch (currentTagMode) {
@@ -475,7 +544,7 @@ int main(void) {
} }
int _write(int file, char *ptr, int len) { int _write(int file, char *ptr, int len) {
UART_SendBytes(1, ptr, len); UART_SendBytes((UART_ID_Type)1, ptr, len);
return len; return len;
} }
@@ -483,27 +552,43 @@ void _putchar(char c) {
_write(0, &c, 1); _write(0, &c, 1);
} }
void applyUpdate() { void applyUpdate(uint32_t size) {
uint32_t ofst, now, size, pieceSz = 0x2000; uint32_t ofst, now, pieceSz = 0x2000;
uint8_t chunkStore[0x2000]; uint8_t chunkStore[0x2000];
printf("Applying update\r\n"); printf("Applying update\r\n");
// apparently, the flash process is more reliable if we do these two first // apparently, the flash process is more reliable if we do these two first
setupCLKCalib(); setupCLKCalib();
setupRTC(); setupRTC(0);
uint64_t test;
FLASH_Read((FLASH_ReadMode_Type)0, fsEnd + 0x0168, (uint8_t *)&test, 8);
if (test != magic) {
printf("Update didn't have the correct magic number!\n");
printf("got %llu\n", test);
delay(1000);
return;
}
showApplyUpdate(); showApplyUpdate();
size = EEPROM_OS_LEN; printf("Applying update\r\n");
// qspiEraseRange(EEPROM_OS_START, EEPROM_OS_LEN);
for (ofst = 0; ofst < size; ofst += now) { for (ofst = 0; ofst < size; ofst += now) {
now = size - ofst; now = size - ofst;
if (now > pieceSz) if (now > pieceSz)
now = pieceSz; now = pieceSz;
printf("Cpy 0x%06x + 0x%04x to 0x%06x\r\n", EEPROM_UPDATE_START + ofst, now, EEPROM_OS_START + ofst); printf("Cpy 0x%06x + 0x%04x to 0x%06x\r\n", fsEnd + ofst, now, ofst);
FLASH_Read(0, EEPROM_UPDATE_START + ofst, chunkStore, now); FLASH_Read((FLASH_ReadMode_Type)0, fsEnd + ofst, chunkStore, now);
protectedFlashWrite(EEPROM_OS_START + ofst, chunkStore, now); // qspiEraseRange(ofst, now);
protectedFlashWrite(ofst, chunkStore, now);
WDT_RestartCounter(); WDT_RestartCounter();
} }
printf("Resetting!\n");
delay(1000);
NVIC_SystemReset(); NVIC_SystemReset();
while (1)
;
} }

View File

@@ -3,32 +3,31 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "core_cm3.h" //#include "core_cm3.h"
#define NO_GUI 0 // Set this to one for faster developing, not Refresh on the E-Paper while showing Full screen messages #define NO_GUI 0 // Set this to one for faster developing, not Refresh on the E-Paper while showing Full screen messages
#define TEST_PIN 3 #define TEST_PIN GPIO_3
#define RF_WAKEUP_PIN 5 #define RF_WAKEUP_PIN GPIO_5
#define UART_TX 4 #define UART_TX GPIO_4
#define UART_RX 6 #define UART_RX GPIO_6
#define NFC_POWER 1 #define NFC_POWER GPIO_1
#define NFC_IRQ 7 #define NFC_IRQ GPIO_7
#define NFC_SCL 28 #define NFC_SCL GPIO_28
#define NFC_SDA 29 #define NFC_SDA GPIO_29
#define EPD_BS 2 #define EPD_BS GPIO_2
#define EPD_MOSI 12 #define EPD_MOSI GPIO_12
#define EPD_MISO 13 #define EPD_MISO GPIO_13
#define EPD_CLK 22 #define EPD_CLK GPIO_22
#define EPD_CS 23 #define EPD_CS GPIO_23
#define EPD_RESET 24 #define EPD_RESET GPIO_24
#define EPD_DC 26 #define EPD_DC GPIO_26
#define EPD_BUSY 27 #define EPD_BUSY GPIO_27
#define EPD_HLT_CTRL 25 #define EPD_HLT_CTRL GPIO_25
#define RADIO_FIRST_CHANNEL (11) //2.4-GHz channels start at 11 #define RADIO_FIRST_CHANNEL (11) //2.4-GHz channels start at 11
void applyUpdate(uint32_t len);
void applyUpdate();

View File

@@ -0,0 +1,16 @@
## 'Filesystem' tools for 88MZ100 ##
- compile_fs_tools.sh
- Compiles 'genprofile.cpp' and and 'mkfs.oepl.cpp' utilities. Expects g++ in paths
- mkfs.oepl.sh
- Converts relevant images to binaries, generates a tag profile, and assembles a binary filesystem
- genprofile
- Generates a binary tag profile from 'tagprofile.json'
- mkbinaryimage.py
- Generates OEPL-compatible binary image file
- mkfs.oepl
- Optionally compresses files and fonts and assembles them into a filesystem
- tagprofile.json
- Tag profile. Used if the serial flasher is used to flash/program a tag. Contains type and mac address
![image](https://github.com/jjwbruijn/OpenEPaperLink/assets/2544995/adb53e40-0b8a-4130-9f28-6ac8f008d54b)

View File

@@ -0,0 +1,7 @@
rm mkfs.oepl genprofile
g++ mkfs.oepl.cpp -lz -o mkfs.oepl
g++ genprofile.cpp -o genprofile
chmod +x mkfs.oepl
chmod +x genprofile

View File

@@ -0,0 +1,61 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
// #include <iostream>
#include <vector>
#include <string.h>
#include <iostream>
#include <fstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
#include "../tagprofile_struct.h"
struct tagHardwareProfile* getProfileFromJson();
int main() {
struct tagHardwareProfile* thwp = getProfileFromJson();
printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X, xRes: %d\n", thwp->macAddress[0],thwp->macAddress[1],thwp->macAddress[2],thwp->macAddress[3],thwp->macAddress[4],thwp->macAddress[5],thwp->macAddress[6],thwp->macAddress[7], thwp->xRes);
FILE* wptr = fopen("tagprofile.bin", "wb");
fwrite((uint8_t*)thwp, sizeof(struct tagHardwareProfile), 1, wptr);
fclose(wptr);
}
struct tagHardwareProfile* getProfileFromJson() {
struct tagHardwareProfile* thwp = new struct tagHardwareProfile;
std::ifstream f("tagprofile.json");
json jsonData = json::parse(f);
// Check if the 'mac' key exists in the JSON object
if (jsonData.find("mac") != jsonData.end()) {
std::string macString = jsonData["mac"];
thwp->xRes = jsonData["xRes"];
thwp->yRes = jsonData["yRes"];
thwp->bpp = jsonData["bpp"];
thwp->controllerType = jsonData["controllerType"];
thwp->OEPLType = jsonData["OEPLType"];
// Attempt to parse the MAC address with ":" separators
int resultWithColons = sscanf(macString.c_str(), "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
&thwp->macAddress[0], &thwp->macAddress[1], &thwp->macAddress[2], &thwp->macAddress[3],
&thwp->macAddress[4], &thwp->macAddress[5], &thwp->macAddress[6], &thwp->macAddress[7]);
if (resultWithColons != 8) {
int resultWithoutColons = sscanf(macString.c_str(), "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
&thwp->macAddress[0], &thwp->macAddress[1], &thwp->macAddress[2], &thwp->macAddress[3],
&thwp->macAddress[4], &thwp->macAddress[5], &thwp->macAddress[6], &thwp->macAddress[7]);
// Check if either format successfully parsed the MAC address
if (resultWithoutColons != 8) {
std::cerr << "Error parsing MAC address from JSON string." << std::endl;
delete thwp;
return nullptr;
}
}
return thwp;
} else {
std::cerr << "Error: 'mac' key not found in JSON." << std::endl;
delete thwp;
return nullptr;
}
}

View File

@@ -0,0 +1 @@
MAC_BEGINS_HERE>

View File

@@ -0,0 +1,95 @@
import sys
from PIL import Image
import struct
import math
def convert_image_to_binary(input_image_path, output_file_path):
# Open the image
img = Image.open(input_image_path)
# Calculate the padded X size
new_x_size = math.ceil(img.size[0] / 8) * 8
# Create a new image with the padded X size
img_padded = Image.new("RGB", (new_x_size, img.size[1]), (255, 255, 255))
img_padded.paste(img, (0, 0))
# Convert the padded image to grayscale and invert
img_bw = img_padded.convert('L').point(lambda x: 255 - x)
# Check if the image has a red channel
has_red_channel = 'R' in img.getbands()
pixel_data_red = img_padded.split()[0].point(lambda x: 255 - x).tobytes()
if any(pixel_data_red):
has_red_channel = 1;
else:
has_red_channel = 0;
# Calculate unpadded resolution
unpadded_resolution = (img.size[0], img.size[1])
# Create binary file
with open(output_file_path, "wb") as binary_file:
# Write header: 0x06, unpadded X size, Y size, bits-per-pixel
binary_file.write(b'\x06')
binary_file.write(unpadded_resolution[0].to_bytes(2, byteorder='little'))
binary_file.write(unpadded_resolution[1].to_bytes(2, byteorder='little'))
# Determine bits-per-pixel
bits_per_pixel = 2 if has_red_channel else 1
binary_file.write(bits_per_pixel.to_bytes(1, byteorder='big'))
# Extract pixel data
pixel_data_bw = img_bw.tobytes()
# If there's a red channel, extract red pixels
if has_red_channel:
pixel_data_red = img_padded.split()[0].point(lambda x: 255 - x).tobytes()
# Process pixel data in chunks of 8 and pack into bytes for black/white
packed_data_bw = bytearray()
packed_data_red = bytearray()
for i in range(0, len(pixel_data_bw), 8):
chunk_bw = pixel_data_bw[i:i + 8]
packed_byte_bw = 0
for j, pixel_value in enumerate(chunk_bw):
packed_byte_bw |= (pixel_value >> j) & 1 << (7 - j)
packed_data_bw.append(packed_byte_bw)
chunk_red = pixel_data_red[i:i + 8]
packed_byte_red = 0
for j, pixel_value in enumerate(chunk_red):
packed_byte_red |= (pixel_value >> j) & 1 << (7 - j)
packed_byte_red = packed_byte_red ^ packed_byte_bw
packed_data_red.append(packed_byte_red)
# Write packed pixel data to binary file
binary_file.write(bytes(packed_data_bw))
binary_file.write(bytes(packed_data_red))
else:
# Process pixel data in chunks of 8 and pack into bytes for black/white
packed_data_bw = bytearray()
for i in range(0, len(pixel_data_bw), 8):
chunk_bw = pixel_data_bw[i:i + 8]
packed_byte_bw = 0
for j, pixel_value in enumerate(chunk_bw):
packed_byte_bw |= (pixel_value >> j) & 1 << (7 - j)
packed_data_bw.append(packed_byte_bw)
# Write packed pixel data to binary file
binary_file.write(bytes(packed_data_bw))
print(f"Conversion completed. Output saved to {output_file_path}")
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python script_name.py input_image_path output_file_path")
else:
input_image_path = sys.argv[1]
output_file_path = sys.argv[2]
convert_image_to_binary(input_image_path, output_file_path)

View File

@@ -0,0 +1,258 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
//#include <iostream>
#include <vector>
#include <string.h>
#include <zlib.h>
#pragma pack(1)
/*
This prepares a FS binary for use with the 88mz100-based OEPL Tag Firmware
Jelmer Bruijn 2024
*/
#define PROGMEM
//#define WINDOW_SIZE 12 // 4096 bytes
#define WINDOW_SIZE 10 // 1024 bytes
#define FILENAME_LENGTH 32
typedef struct {
uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap
uint8_t width; ///< Bitmap dimensions in pixels
uint8_t height; ///< Bitmap dimensions in pixels
uint8_t xAdvance; ///< Distance to advance cursor (x axis)
int8_t xOffset; ///< X dist from cursor pos to UL corner
int8_t yOffset; ///< Y dist from cursor pos to UL corner
} GFXglyph;
/// Data stored for FONT AS A WHOLE
typedef struct {
uint8_t *bitmap; ///< Glyph bitmaps, concatenated
GFXglyph *glyph; ///< Glyph array
uint16_t first; ///< ASCII extents (first char)
uint16_t last; ///< ASCII extents (last char)
uint8_t yAdvance; ///< Newline distance (y axis)
} GFXfont;
typedef struct {
uint16_t first;
uint16_t last;
uint8_t yAdvance;
char glyphFile[FILENAME_LENGTH];
char bitmapFile[FILENAME_LENGTH];
} GFXFontOEPL;
typedef struct {
char name[FILENAME_LENGTH];
uint32_t offset;
uint32_t len;
} OEPLFile;
std::vector<OEPLFile*> files;
uint8_t* buffer = nullptr; // temporary holds the entire FS
uint32_t curOffset = 0;
char OEPLHeader[12] = "---OEPL_FS!";
FILE *wptr;
void dump(const uint8_t *a, const uint16_t l) {
printf("\n ");
#define ROWS 16
for (uint8_t c = 0; c < ROWS; c++) {
printf(" %02X", c);
}
printf("\n--------");
for (uint8_t c = 0; c < ROWS; c++) {
printf("---");
}
for (uint16_t c = 0; c < l; c++) {
if ((c % ROWS) == 0) {
printf("\n0x%04X | ", c);
}
printf("%02X ", a[c]);
}
printf("\n--------");
for (uint8_t c = 0; c < ROWS; c++) {
printf("---");
}
printf("\n");
}
unsigned long doCompress(uint8_t* in, uint32_t in_len, uint8_t* out) {
*((uint32_t*)out) = in_len;
z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.opaque = Z_NULL;
stream.avail_in = (uInt)in_len;
stream.next_in = (Bytef*)in;
stream.avail_out = (uInt)(in_len+1337);
stream.next_out = (Bytef*)(out+4);
*((uint32_t*)out) = in_len;
if (deflateInit2(&stream, Z_BEST_COMPRESSION, Z_DEFLATED, WINDOW_SIZE, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
fprintf(stderr, "Error initializing zlib for compression\n");
return 1;
}
if (deflate(&stream, Z_FINISH) != Z_STREAM_END) {
fprintf(stderr, "Error compressing data\n");
deflateEnd(&stream);
return 1;
}
if (deflateEnd(&stream) != Z_OK) {
fprintf(stderr, "Error finalizing compression\n");
return 1;
}
//dump(out, 16);
return stream.total_out+4;
}
void addFile(uint8_t* filedata, uint16_t len, char* filename, bool compress){
char newfilename[FILENAME_LENGTH];
if(compress){
if(strlen(filename)>(FILENAME_LENGTH-3)){
printf("Filename '%s' is too long\n", filename);
return;
}
uint8_t* tmpbuffer = (uint8_t*)malloc(len + 1337);
unsigned long out_len = doCompress(filedata, len, tmpbuffer);
if(out_len==1){
printf("Compression of %s failed\n", filename);
return;
}
filedata = tmpbuffer;
uint8_t rounded = (uint8_t)((float)100*out_len/len);
printf("Compressed %s \033[50D\033[40C: %u \033[50D\033[47C -> %lu \033[70D\033[58C(%d%%)\n", filename, len, out_len, rounded);
len = out_len;
uint8_t flen = strlen(filename);
strncpy(newfilename,filename,FILENAME_LENGTH-3);
strcpy(newfilename + flen, ".z");
filename = newfilename;
}
if(strlen(filename)>(FILENAME_LENGTH-1)){
printf("Filename '%s' is too long\n", filename);
return;
}
if(!buffer){
buffer = (uint8_t*)malloc(len);
} else {
buffer = (uint8_t*)realloc((void*)buffer, curOffset + len);
}
memcpy(buffer+curOffset, filedata, len);
if(compress)free(filedata);
OEPLFile* file = new OEPLFile;
strcpy(file->name,filename);
file->offset = curOffset;
file->len = len;
files.push_back(file);
curOffset+=len;
}
void addFileFromFS(const char* filename, bool compress){
FILE* file = fopen(filename, "rb");
if (file == NULL) {
fprintf(stderr, "Error opening file: %s\n", filename);
return;
}
fseek(file, 0, SEEK_END);
long fileSize = ftell(file);
rewind(file);
char* fileContent = (char*)malloc(fileSize);
if (fileContent == NULL) {
fprintf(stderr, "Error allocating memory for file content\n");
fclose(file);
return;
}
size_t bytesRead = fread(fileContent, 1, fileSize, file);
addFile((uint8_t*)fileContent, fileSize, (char*)filename, compress);
}
void printFAT(){
printf("OEPL Filesystem Summary:\n");
uint16_t tableSize = files.size() * sizeof(OEPLFile);
tableSize += sizeof(OEPLHeader)-1;
fwrite(OEPLHeader,sizeof(OEPLHeader)-1,1,wptr);
uint32_t fssize = 0;
for(OEPLFile* file : files){
file->offset += tableSize;
fwrite((uint8_t*)file,sizeof(OEPLFile),1,wptr);
printf("file: %s \033[50D\033[37C size=%u \033[50D\033[51C offset=0x%04X\n",file->name, file->len, file->offset);
fssize = file->len + file->offset;
}
printf("Total FS size: %u\n", fssize);
}
void saveFontData(const GFXfont* font, char* name){
if(strlen(name)>(FILENAME_LENGTH-7)){
printf("Font filename '%s' is too long\n", name);
return;
}
GFXFontOEPL fontdata;
fontdata.first = font->first;
fontdata.last = font->last;
fontdata.yAdvance = font->yAdvance;
strcpy(fontdata.glyphFile, name);
strcpy(fontdata.bitmapFile, name);
uint8_t len = strlen(fontdata.glyphFile);
strcpy(fontdata.glyphFile + len, ".glyph");
strcpy(fontdata.bitmapFile + len, ".bmp");
addFile((uint8_t*)&fontdata, sizeof(GFXFontOEPL), name, false);
uint16_t glyphLen = font->last - font->first;
uint16_t lastOffset = font->glyph[glyphLen].bitmapOffset;
uint16_t lastBitmapSize = font->glyph[glyphLen].width * font->glyph[glyphLen].height;
uint8_t lastBitmapBytes = lastBitmapSize/8;
if(lastBitmapSize%8)lastBitmapBytes++;
uint16_t bitmapSize = lastOffset + lastBitmapBytes;
int16_t glyphSize = (glyphLen + 1) * sizeof(GFXglyph);
addFile((uint8_t*)font->glyph, glyphSize, fontdata.glyphFile, false);
addFile((uint8_t*)font->bitmap, bitmapSize, fontdata.bitmapFile, false);
}
#include "../../common/fonts/FreeSans9pt7b.h"
#include "../../common/fonts/FreeSansBold18pt7b.h"
#include "../../common/fonts/FreeSansBold24pt7b.h"
int main(){
wptr = fopen("../build/fs.img","wb"); // w for write, b for binary
/* FONTS */
saveFontData(&FreeSansBold24pt7b, (char*)"font/FreeSansBold24pt7b");
saveFontData(&FreeSansBold18pt7b, (char*)"font/FreeSansBold18pt7b");
saveFontData(&FreeSans9pt7b, (char*)"font/FreeSans9pt7b");
/* OTHER STUFF */
addFileFromFS("marker.txt", false);
addFileFromFS("tagprofile.bin", false);
addFileFromFS("norf.bin", true);
addFileFromFS("lowbat.bin", true);
addFileFromFS("sadpanda.bin", true);
addFileFromFS("tbird2.bin", true);
addFileFromFS("jet.bin", true);
printFAT();
fwrite(buffer,curOffset,1,wptr);
fclose(wptr);
return 0;
}

View File

@@ -0,0 +1,8 @@
python3 mkbinaryimage.py ../../common/assets/norf48.png norf.bin
python3 mkbinaryimage.py ../../common/assets/lowbat48.png lowbat.bin
python3 mkbinaryimage.py ../../common/assets/sadpanda.png sadpanda.bin
python3 mkbinaryimage.py ../../common/assets/tbird2.png tbird2.bin
python3 mkbinaryimage.py ../../common/assets/jet.png jet.bin
./genprofile
./mkfs.oepl

View File

@@ -0,0 +1,8 @@
{
"mac":"00000130C8754110",
"xRes":400,
"yRes":300,
"bpp":2,
"controllerType":1,
"OEPLType":36
}

View File

@@ -0,0 +1,8 @@
{
"mac":"0000021ECA8C743F",
"xRes":640,
"yRes":384,
"bpp":2,
"controllerType":0,
"OEPLType":5
}

View File

@@ -0,0 +1,8 @@
{
"mac":"000001EF0ED27336",
"xRes":640,
"yRes":384,
"bpp":1,
"controllerType":0,
"OEPLType":38
}

View File

@@ -0,0 +1,8 @@
{
"mac":"000001EF0ED27336",
"xRes":640,
"yRes":384,
"bpp":1,
"controllerType":0,
"OEPLType":38
}

View File

@@ -0,0 +1,25 @@
#ifndef _EEPROM_H_
#define _EEPROM_H_
#include <stdint.h>
#define EEPROM_WRITE_PAGE_SZ 256 //max write size & alignment
#define EEPROM_ERZ_SECTOR_SZ 4096 //erase size and alignment
//pages are 4K in size
//an update can be stored in any 2 image slots
#define EEPROM_SETTINGS_AREA_START (0x7F000UL)
#define EEPROM_SETTINGS_SIZE (0x01000UL)
#define EEPROM_TOTAL_SIZE (0x80000UL)
#define EEPROM_MAC_INFO_START (0x6c000UL) //not same as stock
#define EEPROM_MAC_INFO_LEN (0x01000UL)
#define EEPROM_IMG_VALID (0x494d4721)
//#define EEPROM_PIECE_SZ (88)
#include "../../common/eeprom_struct.h"
#endif

View File

@@ -1,11 +1,11 @@
#include "nfc.h" #include "nfc.h"
//#include <stdio.h> // #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "core_cm3.h" #include "core_cm3.h"
#include "main.h" #include "../main.h"
#include "mz100_rtc.h" #include "mz100_rtc.h"
#include "mz100_wdt.h" #include "mz100_wdt.h"
#include "mz100_pmu.h" #include "mz100_pmu.h"
@@ -14,38 +14,46 @@
#include "util.h" #include "util.h"
#include "printf.h" #include "printf.h"
#include "mz100_clock.h"
void NVIC_some_IRQ1(unsigned int a1) volatile bool RTCintFired = false;
{
void setupWDT() {
//** WATCHDOG
CLK_ModuleClkEnable(CLK_WDT);
WDT_SetMode(WDT_MODE_RESET);
WDT_SetResetPulseLen(WDT_RESET_PULSE_LEN_256);
WDT_SetTimeoutVal(0x0B);
WDT_RestartCounter();
WDT_Enable();
//** WATCHDOG
}
void NVIC_some_IRQ1(unsigned int a1) {
*(uint32_t *)(4 * (a1 >> 5) - 0x1FFF1E80) = 1 << (a1 & 0x1F); *(uint32_t *)(4 * (a1 >> 5) - 0x1FFF1E80) = 1 << (a1 & 0x1F);
} }
void NIVC_some_IRQ(unsigned int a1) void NIVC_some_IRQ(unsigned int a1) {
{
*(uint32_t *)(4 * (a1 >> 5) - 0x1FFF1D80) = 1 << (a1 & 0x1F); *(uint32_t *)(4 * (a1 >> 5) - 0x1FFF1D80) = 1 << (a1 & 0x1F);
} }
void Pin_pad_set_Low(int pin) void Pin_pad_set_Low(int pin) {
{
GPIO_PinPadOutputEnable(pin); GPIO_PinPadOutputEnable(pin);
GPIO_PinPadOutputLevel(pin, PIN_PAD_OUTPUT_LOW); GPIO_PinPadOutputLevel(pin, PIN_PAD_OUTPUT_LOW);
GPIO_PinOutputModeConfig(pin, PIN_OUTPUT_MODE_PAD); GPIO_PinOutputModeConfig(pin, PIN_OUTPUT_MODE_PAD);
} }
void Pin_pad_set_High(int pin) void Pin_pad_set_High(int pin) {
{
GPIO_PinPadOutputEnable(pin); GPIO_PinPadOutputEnable(pin);
GPIO_PinPadOutputLevel(pin, PIN_PAD_OUTPUT_HIGH); GPIO_PinPadOutputLevel(pin, PIN_PAD_OUTPUT_HIGH);
GPIO_PinOutputModeConfig(pin, PIN_OUTPUT_MODE_PAD); GPIO_PinOutputModeConfig(pin, PIN_OUTPUT_MODE_PAD);
} }
void Pin_pad_set_Normal(int pin) void Pin_pad_set_Normal(int pin) {
{
GPIO_PinPadOutputEnable(pin); GPIO_PinPadOutputEnable(pin);
GPIO_PinPadOutputLevel(pin, PIN_PAD_OUTPUT_LOW); GPIO_PinPadOutputLevel(pin, PIN_PAD_OUTPUT_LOW);
GPIO_PinOutputModeConfig(pin, PIN_OUTPUT_MODE_NORMAL_FUNCTION); GPIO_PinOutputModeConfig(pin, PIN_OUTPUT_MODE_NORMAL_FUNCTION);
} }
void init_GPIO_boot() void init_GPIO_boot() {
{
Pin_pad_set_Normal(NFC_POWER); Pin_pad_set_Normal(NFC_POWER);
Pin_pad_set_Normal(NFC_IRQ); Pin_pad_set_Normal(NFC_IRQ);
Pin_pad_set_Normal(EPD_MOSI); Pin_pad_set_Normal(EPD_MOSI);
@@ -59,10 +67,9 @@ void init_GPIO_boot()
Pin_pad_set_Normal(EPD_RESET); Pin_pad_set_Normal(EPD_RESET);
Pin_pad_set_Normal(EPD_HLT_CTRL); Pin_pad_set_Normal(EPD_HLT_CTRL);
} }
void init_GPIO_sleep() void init_GPIO_sleep() {
{
Pin_pad_set_Low(NFC_POWER); Pin_pad_set_Low(NFC_POWER);
//Pin_pad_set_Low(NFC_IRQ); // Pin_pad_set_Low(NFC_IRQ);
Pin_pad_set_Low(EPD_MOSI); Pin_pad_set_Low(EPD_MOSI);
Pin_pad_set_Low(EPD_MISO); Pin_pad_set_Low(EPD_MISO);
Pin_pad_set_Low(EPD_CLK); Pin_pad_set_Low(EPD_CLK);
@@ -77,10 +84,8 @@ void init_GPIO_sleep()
uint8_t WAKEUP_RF = 0; uint8_t WAKEUP_RF = 0;
void __attribute__((interrupt)) ExtPin5_IRQHandler(void) void __attribute__((interrupt)) ExtPin5_IRQHandler(void) {
{ if (!WAKEUP_RF) {
if (!WAKEUP_RF)
{
NVIC_ClearPendingIRQ(ExtPin5_IRQn); NVIC_ClearPendingIRQ(ExtPin5_IRQn);
GPIO_IntMask(RF_WAKEUP_PIN, MASK); GPIO_IntMask(RF_WAKEUP_PIN, MASK);
NVIC_some_IRQ1(ExtPin5_IRQn); NVIC_some_IRQ1(ExtPin5_IRQn);
@@ -90,10 +95,17 @@ void __attribute__((interrupt)) ExtPin5_IRQHandler(void)
} }
} }
uint32_t gSleepRtcCounter = 0; void __attribute__((interrupt)) ExtPin7_IRQHandler(void) {
uint8_t Ext_Pin27_triggered = 0; NVIC_ClearPendingIRQ(ExtPin7_IRQn);
void __attribute__((interrupt)) ExtPin27_IRQHandler(void) GPIO_IntMask(NFC_IRQ, MASK);
{ NVIC_some_IRQ1(ExtPin7_IRQn);
PMU_ClearWakeupExtpin(PMU_GPIO7_INT);
NVIC_ClearPendingIRQ(ExtPin7_IRQn);
}
volatile uint32_t gSleepRtcCounter = 0;
volatile uint8_t Ext_Pin27_triggered = 0;
void __attribute__((interrupt)) ExtPin27_IRQHandler(void) {
WDT_RestartCounter(); WDT_RestartCounter();
printf(">>PIN_27_IRQHandler\r\n"); printf(">>PIN_27_IRQHandler\r\n");
NVIC_ClearPendingIRQ(ExtPin27_IRQn); NVIC_ClearPendingIRQ(ExtPin27_IRQn);
@@ -104,33 +116,26 @@ void __attribute__((interrupt)) ExtPin27_IRQHandler(void)
Ext_Pin27_triggered = 1; Ext_Pin27_triggered = 1;
} }
void enable_irq_for_pin(int a1, unsigned int a2) void enable_irq_for_pin(int a1, unsigned int a2) {
{ PMU_WakeupPinSrc_Type v4; // r0
PMU_WakeupPinSrc_Type v4; // r0 PMU_WakeupPinSrc_Type v5; // r5
PMU_WakeupPinSrc_Type v5; // r5 char v6; // r7
char v6; // r7 PMU_WakeupTrigMode_Type v7; // r1
PMU_WakeupTrigMode_Type v7; // r1
GPIO_PinMuxFun(a2, 7); GPIO_PinMuxFun(a2, 7);
if (a2 > 7) if (a2 > 7) {
{
if (a2 - 26 > 5) if (a2 - 26 > 5)
return; return;
v4 = a2 - 19; v4 = a2 - 19;
} } else {
else
{
v4 = a2 - 1; v4 = a2 - 1;
} }
v5 = v4; v5 = v4;
v6 = a2 + 31; v6 = a2 + 31;
if (a1 == 1) if (a1 == 1) {
{
GPIO_PinModeConfig(a2, PINMODE_PULLDOWN); GPIO_PinModeConfig(a2, PINMODE_PULLDOWN);
v7 = PMU_WAKEUP_EDGE_RISING; v7 = PMU_WAKEUP_EDGE_RISING;
} } else {
else
{
if (a1 != 2) if (a1 != 2)
goto LABEL_11; goto LABEL_11;
GPIO_PinModeConfig(a2, PINMODE_PULLUP); GPIO_PinModeConfig(a2, PINMODE_PULLUP);
@@ -144,13 +149,13 @@ LABEL_11:
NVIC_EnableIRQ(v6); NVIC_EnableIRQ(v6);
} }
void wait_busy_sleep(int a1) void wait_busy_sleep(int a1) {
{
unsigned int v1 = 0; unsigned int v1 = 0;
gSleepRtcCounter = 0; gSleepRtcCounter = 0;
printf("=> EPD_BUSYN_PIN : %d\r\n", 27); // printf("=> EPD_BUSYN_PIN : %d\r\n", 27);
while (1) delay(1);
{
while (1) {
RTC_CounterReset(); RTC_CounterReset();
RTC_IntClr(RTC_INT_CNT_UPP); RTC_IntClr(RTC_INT_CNT_UPP);
NIVC_some_IRQ(0); NIVC_some_IRQ(0);
@@ -163,10 +168,7 @@ void wait_busy_sleep(int a1)
if (Ext_Pin27_triggered == 1) if (Ext_Pin27_triggered == 1)
break; break;
v1++; v1++;
delay(2000); if (v1 >= 0x5A) {
printf("busypin:%d,SCNT:%d\r\n", GPIO_ReadPinLevel(EPD_BUSY), v1);
if (v1 >= 0x5A)
{
printf("DRF BUSY CHECK FAIL\r\n"); printf("DRF BUSY CHECK FAIL\r\n");
break; break;
} }
@@ -176,7 +178,7 @@ void wait_busy_sleep(int a1)
NIVC_some_IRQ(0); NIVC_some_IRQ(0);
(*(volatile unsigned int *)0xE000E180) = 1; (*(volatile unsigned int *)0xE000E180) = 1;
gSleepRtcCounter = 1000 * RTC_GetCounterVal() / 0x7FFFu + a1 * v1; gSleepRtcCounter = 1000 * RTC_GetCounterVal() / 0x7FFFu + a1 * v1;
printf("RTC_GetCounterVal(): %d, gSleepRtcCounter:%d(ms)\r\n", RTC_GetCounterVal(), gSleepRtcCounter); // printf("RTC_GetCounterVal(): %d, gSleepRtcCounter:%d(ms)\r\n", RTC_GetCounterVal(), gSleepRtcCounter);
RTC_CounterReset(); RTC_CounterReset();
Ext_Pin27_triggered = 0; Ext_Pin27_triggered = 0;
GPIO_SetPinDir(EPD_BUSY, GPIO_INPUT); GPIO_SetPinDir(EPD_BUSY, GPIO_INPUT);
@@ -184,14 +186,13 @@ void wait_busy_sleep(int a1)
GPIO_PinModeConfig(EPD_BUSY, PINMODE_PULLUP); GPIO_PinModeConfig(EPD_BUSY, PINMODE_PULLUP);
} }
void do_sleeped_epd_refresh() void do_sleeped_epd_refresh() {
{
printf("PM2 MODE START!\r\n"); printf("PM2 MODE START!\r\n");
PMU->PMIP_BRN.BF.BRNDET_EN = 0; PMU->PMIP_BRN.BF.BRNDET_EN = 0;
PMU->PWR_MODE.BF.CAU_ON = 0; PMU->PWR_MODE.BF.CAU_ON = 0;
PMU->PMIP_CHP_CTRL.BF.CHP_ON_OFF = 1; PMU->PMIP_CHP_CTRL.BF.CHP_ON_OFF = 1;
PMU_SetSleepMode(PMU_PM2); PMU_SetSleepMode(PMU_PM2);
PMU_ClearWakeupExtpin(PMU_GPIO5_INT); PMU_ClearWakeupExtpin(PMU_GPIO5_INT);
wait_busy_sleep(2000); wait_busy_sleep(500);
printf("uDisTime : %d ms\r\n", gSleepRtcCounter); printf("uDisTime : %d ms\r\n", gSleepRtcCounter);
} }

View File

@@ -1,5 +1,7 @@
#pragma once #pragma once
void setupWDT();
void NVIC_some_IRQ1(unsigned int a1); void NVIC_some_IRQ1(unsigned int a1);
void NIVC_some_IRQ(unsigned int a1); void NIVC_some_IRQ(unsigned int a1);
void init_GPIO_boot(); void init_GPIO_boot();

View File

@@ -3,8 +3,8 @@ GROUP(-lgcc -lc -lnosys)
MEMORY MEMORY
{ {
FLASH (rx) : ORIGIN = 0x100000, LENGTH = 80k FLASH (rx) : ORIGIN = 0x100000, LENGTH = 90k
RAM (rwx) : ORIGIN = 0x20100000 + 80k, LENGTH = 160k - 80k - 2k RAM (rwx) : ORIGIN = 0x20100000 + 90k, LENGTH = 160k - 90k - 2k
AONSHADOW (rwx) : ORIGIN = 0x20128000 - 2k, LENGTH = 2k AONSHADOW (rwx) : ORIGIN = 0x20128000 - 2k, LENGTH = 2k
AON (rwx) : ORIGIN = 0x20130000 , LENGTH = 4k AON (rwx) : ORIGIN = 0x20130000 , LENGTH = 4k
} }
@@ -17,7 +17,7 @@ SECTIONS
{ {
KEEP(*(.isr_vector)) KEEP(*(.isr_vector))
KEEP(*(.ver)) KEEP(*(.ver))
KEEP(*(.default_mac)) KEEP(*(.fwmagic))
*(.text*) *(.text*)
KEEP(*(.init)) KEEP(*(.init))

View File

@@ -11,19 +11,20 @@ bool aonRamValid = false;
void clearAonRam() { void clearAonRam() {
memset((void *)0x130000, 0, 4096); memset((void *)0x130000, 0, 4096);
//memcpy((void *)(0x128000 - AONSHADOW_SIZE), (uint8_t *)aonShadow, AONSHADOW_SIZE);
} }
bool loadValidateAonRam() { bool loadValidateAonRam() {
uint32_t testchecksum = aonChecksum; uint32_t testchecksum = aonChecksum;
aonChecksum = 0x00000000; aonChecksum = 0x00000000;
uint32_t checksum = 0xABBA5FF5; uint32_t checksum = 0xABBA5FF7;
for (uint32_t c = 0x130000; c < 0x131000; c += 4) { for (uint32_t c = 0x130000; c < 0x131000; c += 4) {
checksum += *(uint32_t *)c; checksum += *(uint32_t *)c;
} }
if (checksum == testchecksum) { if (checksum == testchecksum) {
// immediately invalidate the checksum; if we reboot, we want a clean reboot // immediately invalidate the checksum; if we reboot, we want a clean reboot
aonChecksum = 0x5445A00A; aonChecksum = 0x5445A00A;
memcpy((void *)(0x128000 - AONSHADOW_SIZE), (uint8_t*)aonShadow, AONSHADOW_SIZE); memcpy((void *)(0x128000 - AONSHADOW_SIZE), (uint8_t *)aonShadow, AONSHADOW_SIZE);
return true; return true;
} else { } else {
clearAonRam(); clearAonRam();
@@ -33,9 +34,9 @@ bool loadValidateAonRam() {
} }
void saveAonRam() { void saveAonRam() {
memcpy((uint8_t*)aonShadow, (void *)(0x128000 - AONSHADOW_SIZE), AONSHADOW_SIZE); memcpy((uint8_t *)aonShadow, (void *)(0x128000 - AONSHADOW_SIZE), AONSHADOW_SIZE);
aonChecksum = 0x00000000; aonChecksum = 0x00000000;
uint32_t checksum = 0xABBA5FF5; uint32_t checksum = 0xABBA5FF7;
for (uint32_t c = 0x130000; c < 0x131000; c += 4) { for (uint32_t c = 0x130000; c < 0x131000; c += 4) {
checksum += *(uint32_t *)c; checksum += *(uint32_t *)c;
} }

View File

@@ -12,8 +12,8 @@
#include "mz100_sleep.h" #include "mz100_sleep.h"
#include "util.h" #include "util.h"
#include "gpio.h" #include "gpio.h"
#include "main.h" #include "../main.h"
#include "proto.h" //#include "proto.h"
#include "printf.h" #include "printf.h"
extern void saveAonRam(); extern void saveAonRam();
@@ -88,16 +88,16 @@ void Set_Wakeup_pin_nfc()
NVIC_EnableIRQ(ExtPin7_IRQn); NVIC_EnableIRQ(ExtPin7_IRQn);
} }
extern struct blockRequest curBlock; // used by the block-requester, contains the next request that we'll send //extern struct blockRequest curBlock; // used by the block-requester, contains the next request that we'll send
extern struct AvailDataInfo curDataInfo; // last 'AvailDataInfo' we received from the AP //extern struct AvailDataInfo xferDataInfo; // last 'AvailDataInfo' we received from the AP
extern bool requestPartialBlock; // if we should ask the AP to get this block from the host or not //extern bool requestPartialBlock; // if we should ask the AP to get this block from the host or not
void sleep_with_with_wakeup(uint32_t sleep_time_ms) void sleep_with_with_wakeup(uint32_t sleep_time_ms)
{ {
saveAonRam(); saveAonRam();
//memcpy((uint8_t *)&(*(volatile unsigned int *)0x130500), (uint8_t *)&curBlock, sizeof(struct blockRequest)); //memcpy((uint8_t *)&(*(volatile unsigned int *)0x130500), (uint8_t *)&curBlock, sizeof(struct blockRequest));
//memcpy((uint8_t *)&(*(volatile unsigned int *)0x130600), (uint8_t *)&curDataInfo, sizeof(struct AvailDataInfo)); //memcpy((uint8_t *)&(*(volatile unsigned int *)0x130600), (uint8_t *)&curDataInfo, sizeof(struct AvailDataInfo));
//sleep_time_ms = 10000; //sleep_time_ms = 10000;
printf("sleep! %u\n", sleep_time_ms); //printf("sleep! %u\n", sleep_time_ms);
uint32_t sleep_time_ms_1; uint32_t sleep_time_ms_1;
AON_level_VDD(7); AON_level_VDD(7);
AON_level_VAA(0); AON_level_VAA(0);

View File

@@ -129,6 +129,7 @@ void WDT_SetMode(WDT_Mode_Type mode)
void WDT_SetTimeoutVal(uint32_t timeoutVal) void WDT_SetTimeoutVal(uint32_t timeoutVal)
{ {
/* set WDT timeout value */ /* set WDT timeout value */
// This value can be anything between 0x00 and 0x0F; this configures the WDT to reset at 2^(16+value) cycles (2^16 - 2^31)
WDT->TORR.BF.TOP = timeoutVal; WDT->TORR.BF.TOP = timeoutVal;
} }

Some files were not shown because too many files have changed in this diff Show More