diff --git a/.citd/Jenkinsfilek8s b/.citd/Jenkinsfilek8s index ed4a00d..ec7687b 100644 --- a/.citd/Jenkinsfilek8s +++ b/.citd/Jenkinsfilek8s @@ -54,6 +54,9 @@ pipeline { MPLABX_PROJECT_SOURCE = "../" } + triggers { + cron(env.BRANCH_NAME == 'develop' ? 'H H 1 * *': '') + } options { timestamps() timeout(time: 20, unit: 'MINUTES') diff --git a/.main-meta/main.json b/.main-meta/main.json index 7681111..4daef93 100644 --- a/.main-meta/main.json +++ b/.main-meta/main.json @@ -4,13 +4,13 @@ "content": { "metaDataVersion": "1.3.0", "name": "com.microchip.mplabx.project.dspic33ck-curiosity-data-eeprom-emulation-demo", - "version": "1.0.1", + "version": "1.1.0", "displayName": "dsPIC33CK Curiosity Data EEPROM Emulation Demo", "projectName": "dspic33ck-curiosity-data-eeprom-emulation-demo", "shortDescription": "dsPIC33CK Curiosity Data EEPROM Emulation Demo", "ide": { "name": "MPLABX", - "semverRange": ">=6.0.0" + "semverRange": ">=6.15.0" }, "compiler": { "name": "XC16", diff --git a/README.md b/README.md index ba237ee..40928bc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![image](images/microchip.jpg) +![image](images/microchip.jpg) ## dsPIC33CK Curiosity Data EEPROM Emulation Demo @@ -10,12 +10,12 @@ Microchip Technology Inc., has expanded its product portfolio to include a wide Many applications store nonvolatile information in the Flash program memory using table read and write operations. Applications that need to frequently update these data may have greater endurance requirements than the specified Flash endurance for the MCU/Digital Signal Controller (DSC) devices. -The alternate solution of using an external, serial EEPROM device may not be appropriate for cost-sensitive or pin-constrained applications. +The alternate solution of using an external, serial EEPROM device may not be appropriate for cost-sensitive or pin-constrained applications. This 16-Bit Data EEPROM Emulation library presents a third alternative that addresses these issues. This library features an interface similar to an internal data EEPROM, which uses available program memory and can improve endurance by a factor as high as 500. -This code example demonstrate the usage of 16-Bit Data EEPROM Emulation Library. +This code example demonstrates the usage of 16-Bit Data EEPROM Emulation Library. ## Related Documentation @@ -23,10 +23,10 @@ This code example demonstrate the usage of 16-Bit Data EEPROM Emulation Library. - Emulating Data EEPROM for PIC18 and PIC24 MCUs and dsPIC33 DSCs (https://www.microchip.com/en-us/application-notes/an1095) -## Software Used +## Software Used -- MPLAB® X IDE v6.00 or newer (https://www.microchip.com/mplabx) -- MPLAB® XC16 v2.00 or newer (https://www.microchip.com/xc) +- MPLAB® X IDE v6.15 or newer (https://www.microchip.com/mplabx) +- MPLAB® XC16 v2.00 or newer (https://www.microchip.com/xc) - Any of the serial terminal application. Example: Tera Term (https://ttssh2.osdn.jp/index.html.en) - 16-bit Data EEPROM Emulation Library (DEE) for PIC24 MCUs and dsPIC33 DSCs (https://www.microchip.com/en-us/software-library/16-bit_data_eeprom_emulation) @@ -36,23 +36,50 @@ This code example demonstrate the usage of 16-Bit Data EEPROM Emulation Library. - dsPIC33CK Curiosity Development Board (https://www.microchip.com/DM330030) - Micro USB Cable - +**Note:** The word panel and partition means the same thing and used interchangeably in this document. ## Operation +There are 2 examples in this repository. Example1 uses single panel and Example2 demonstrates dual panel capability of DEE. +Using dual panel is useful to not cause CPU execution stall during the normal runtime mode when the applications uses the DEE, which would be stored in the inactive partition. -This demo runs the Data EEPROM Emulation , if emulation is succesful then prints a message saying "Data EEPROM Emulation successful. Value at address 0 is 1024 and address1 is 1025" -If emulation fails it prints a message saying "Data EEPROM Emulation failed". +## Example1: +This demo runs the Data EEPROM Emulation , if emulation is successful then prints a message to the serial terminal saying "Data EEPROM Emulation successful. Value at address 0 is 1024 and address1 is 1025" +If emulation fails it prints a message to the serial terminal saying "Data EEPROM Emulation failed". -## Accessing 16-Bit Data EEPROM Emulation Library +## Example2: +There are 2 MPLABX projects under folder "dspic33ck-curiosity-dual-panel-dee-demo". One project for programming the first partition another for programming the second partition. -*Note:* More MCC Melody devices support will be added in future releases. +In a typical field scenario, boot-loader will help to do a live update i.e. boot-loader will help to download the new application to the secondary +partition and this new application will be configured such that on reboot, application in secondary partition will execute(secondary partition +becomes primary or active partition). -| Device Family | Procedure | -| ----------- | ----------- | -| "CK" Family of devices| 1. Create project
2. Launch MCC
3. Select "MCC Melody"

4. "16-Bit Data EEPROM Emulation Library "will be available under "Libraries"
| -| All other devices except "CK" device family | 1. Make sure https://ww1.microchip.com/downloads/en/DeviceDoc/script-1.29.3.mc3lib is installed
2. Create project
3. Launch MCC
4. Select "Classic MCC"

5. Switch core version to "5.2.1"

6. "16-Bit Data EEPROM Emulation Library" will be available under "Libraries"
| +If we want to program both the partitions of the microcontroller, MPLABX provides an option to create an unified hex file for programming both program memory partitions with different applications. In order to do that users have to configure one MPLABX project with XC16(Global Options) ->Partition as "Partition One/Active" and another MPLABX project with XC16(Global Options) ->Partition as "Partition Two/Inactive". Then second MPLABX project needs to be linked to first MPLABX project as loadable as shown below. + +![image](images/projectConfig.jpg) + +The projects in this example are already linked so that when dee-dual-panel-demo-partition1.X is built and programmed, it programs both the partitions. + +After programming, the application in the first partition(active partition) will execute and DEE library will use the inactive partition(second partition) to store the DEE data. User will see the following data on the serial terminal on successful emulation, +![image](images/partition1.jpg) +After some time, once the emulation is completed and output is displayed, user has to reset the board. The application in the first partition, configures the configuration bits BSEQ and IBSEQ in the second partition, such that on reset second partition becomes the active partition. On resetting the board +application in the second partition will execute. DEE Library will check if there is any data available in the active partition from the previous iteration, if so it copies the data to the inactive partition(first partition), delete the previous iteration data from the active partition and continue with the emulation. +The following data will be displayed on successful emulation. +![image](images/partition2.jpg) + +## Important Note +If there is no requirement for partition switching, the entire second partition(inactive partition) can be used for storing the DEE data. If partition switching is required make sure that free space in executable partition(active partition) is larger than the required DEE data structure size. + +## Accessing 16-Bit Data EEPROM Emulation Library + +*Note:* More MCC Melody devices support will be added in future releases. + +| Device Family | Procedure | +| ----------- | ----------- | +| Devices supported on Melody| 1. Create project
2. Launch MCC
3. Select "MCC Melody"

4. "16-Bit Data EEPROM Emulation Library "will be available under "Libraries"
| +| Devices not supported on Melody | 1. Make sure https://ww1.microchip.com/downloads/en/DeviceDoc/script-1.29.3.mc3lib is installed
2. Create project
3. Launch MCC
4. Select "Classic MCC"

5. Switch core version to "5.2.1"

6. "16-Bit Data EEPROM Emulation Library" will be available under "Libraries"
| +For more information refer: https://www.microchip.com/en-us/software-library/dspic33-pic24-data-eeprom-emulation diff --git a/changelog.md b/changelog.md index 66f07d0..05fd3ec 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,13 @@ +# 16-Bit Data EEPROM Emulation Demo v1.1.0 +### Release Highlights + +Added an example project to demonstrate Dual Panel capability of Data EEPROM Emulation Library. + +### Features Added\Updated + +New example demonstrating dual panel capability of Data EEPROM Emulation Library is added. + + # 16-Bit Data EEPROM Emulation Demo v1.0.1 ### Release Highlights @@ -10,6 +20,3 @@ Updated the demo to use the latest version of Melody Initial release of 16-Bit Data EEPROM Emulation Demo ### Features Added\Updated - - - diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/.main-meta/main.json b/dspic33ck-curiosity-dual-panel-dee-demo/.main-meta/main.json new file mode 100644 index 0000000..9606663 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/.main-meta/main.json @@ -0,0 +1,48 @@ +{ + "metaDataVersion": "1.0.0", + "category": "com.microchip.ide.project", + "content": { + "metaDataVersion": "1.3.0", + "name": "com.microchip.mplabx.project.dspic33ck-curiosity-dual-panel-data-eeprom-emulation-demo", + "version": "1.0.0", + "displayName": "dsPIC33CK Curiosity Dual Partition Flash Data EEPROM Emulation Demo", + "projectName": "dspic33ck-curiosity-dual-panel-data-eeprom-emulation-demo", + "shortDescription": "dsPIC33CK Curiosity Dual Partition Flash Data EEPROM Emulation Demo", + "ide": { + "name": "MPLABX", + "semverRange": ">=6.15.0" + }, + "compiler": { + "name": "XC16", + "semverRange": "^2.0.0" + }, + "dfp": { + "name": "dsPIC33CK-MP_DFP", + "semverRange": ">=1.6.176" + }, + "configurator": { + "name": "MCC", + "semverRange": ">=5.1.1" + }, + "device": { + "metaDataVersion": "1.0.0", + "category": "com.microchip.portal.contentRef", + "content": { + "metaDataVersion": "1.0.0", + "category": "com.microchip.device", + "name": "DSPIC33CK256MP508", + "versionRange": "*" + } + }, + "peripherals": [ + "UART", + "FLASH" + ], + "keywords": [ + "EEPROM", + "DEE", + "Data EEPROM Emulation", + "Dual Partition Flash" + ] + } +} \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/Makefile b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/Makefile new file mode 100644 index 0000000..fca8e2c --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/Makefile @@ -0,0 +1,113 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin +RANLIB=ranlib + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... +# WARNING: the IDE does not call this target since it takes a long time to +# simply run make. Instead, the IDE removes the configuration directories +# under build and dist directly without calling make. +# This target is left here so people can do a clean when running a clean +# outside the IDE. + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/dee-dual-panel-demo-partition1.mc3 b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/dee-dual-panel-demo-partition1.mc3 new file mode 100644 index 0000000..642becf --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/dee-dual-panel-demo-partition1.mc3 @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Application Builder + class com.microchip.mcc.melody.module.FrameworkModule + + + Configuration Bits + class com.microchip.mcc.melody.hw.module.HardwareModule + + + DMT + class com.microchip.mcc.melody.hw.module.HardwareModule + + + FLASH + class com.microchip.mcc.melody.hw.module.HardwareModule + + + ICD + class com.microchip.mcc.melody.hw.module.HardwareModule + + + INTERNAL OSCILLATOR + class com.microchip.mcc.melody.hw.module.HardwareModule + + + INTERRUPT CORE + class com.microchip.mcc.melody.hw.module.HardwareModule + + + MAIN MANAGER + class com.microchip.mcc.melody.hw.module.HardwareModule + + + Pin Manager + class com.microchip.mcc.melody.hw.module.HardwareModule + + + RESET + class com.microchip.mcc.melody.hw.module.HardwareModule + + + UART1 + class com.microchip.mcc.melody.hw.module.HardwareModule + + + WATCHDOG + class com.microchip.mcc.melody.hw.module.HardwareModule + + + meta + class com.microchip.mcc.melody.hw.module.HardwareModule + + + module0 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module1 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module123 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module2 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module3 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module31 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module39 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module4 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module47 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module5 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module50 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module6 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module64 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module69 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module77 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module82 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module90 + class com.microchip.mcc.melody.script.module.ScriptModule + + + + + + + + + {"mccDevice":{"loc":"0 0","pos":"0 0"},"systemGroup":{"loc":"0 -75","pos":"0 -75"},"module39":{"loc":"159.5 -45.5","pos":"159.5 -45.5"},"module47":{"loc":"172 0","pos":"172 0"},"module90":{"loc":"325.5 95.5","pos":"325.5 95.5"},"module123":{"loc":"172 70","pos":"172 70"}} + + + + {"userAddedModules":["module5","module4","module6","module39","module1","module0","module3","module2","module64","module31","scf-adapter/importing:16-bit Bootloader:BootloaderModule","module69","module47","scf-adapter/importing:16-bit Bootloader:ApplicationModule","module77","module90","module123","module50","module82"],"version":"CURRENT","modules":{"module5":{"scriptId":"@mchp-mcc/pic24-dspic33-clock-sib","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"pin_standard":{"interfaceId":{"name":"pin-standard","version":"^0.1.0"},"handle":{"providerId":"module4","exportId":"pin-standard"}},"clk_sib_v12":{"interfaceId":{"name":"clk_sib_v12","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"INTERNAL OSCILLATOR"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module4":{"scriptId":"@mchp-mcc/pin-content-processor","imports":{"device-meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"pin-architecture":{"interfaceId":{"name":"pin-architecture","version":"1.0.0"},"handle":{"providerId":"module3","exportId":"pin-architecture"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{"saved":{"userEditedData":{"inputPPSState":{"module39":{"UART1":{"U1RX":"RD3"}}},"cname":{"eview":{"RE5":"LED1","RE6":"LED2"}}},"rows":{"module39":{"UART1$U1TX$output":{"pins":{"RD4":{"state":"L"}}}},"pcp":{"GPIO$GPIO$input":{"pins":{"RE5":{"state":"MUL"},"RE6":{"state":"MUL"}}},"GPIO$GPIO$output":{"pins":{"RE5":{"state":"L"},"RE6":{"state":"L"}}}}}}}},"module6":{"scriptId":"@mchp-mcc/clock-16bit-driver","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"clock_16bit_config_interface":{"interfaceId":{"name":"clock-16bit-config-interface","version":"^1.1.5"},"handle":{"providerId":"module5","exportId":"clock_16bit_config_interface"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{}},"module39":{"scriptId":"@mchp-mcc/pic24-dspic33-uart-protocol-upb","imports":{"pin_standard":{"interfaceId":{"name":"pin-standard","version":"^0.1.0"},"handle":{"providerId":"module4","exportId":"pin-standard"}},"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"uart_protocol_upb_v1":{"interfaceId":{"name":"uart_protocol_upb_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"UART1"}},"clock_16bit_interface":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module5","exportId":"clock_16bit_interface"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"interrupt_service":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module1":{"scriptId":"@mchp-mcc/dspic33-configuration-bits","imports":{"dspic33_configuration_bits":{"interfaceId":{"name":"dspic33_configuration_bits","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"Configuration Bits"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{"main":{"FBOOT":{"btmodeFboot":"DUAL"},"FBTSEQ":{"bseqFbtseq":"0x002","ibseqFbtseq":"0xFFD"}}}},"module0":{"scriptId":"@mchp-mcc/main-16bit-manager","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"main":{"interfaceId":{"name":"main-16bit-manager","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"MAIN MANAGER"}}},"framewSpecificState":{"userEditedImports":[]}},"module3":{"scriptId":"@mchp-mcc/pic24-dspic33-pin-manager","imports":{"pic24-dspic33-pin-manager":{"interfaceId":{"name":"pic24-dspic33-pin-manager","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"Pin Manager"}},"device-meta":{"interfaceId":{"name":"device-meta","version":"^1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"interrupt-16bit-interface":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}},"system-16bit-initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{"adapterdata":{"pps":{"data":{"UART":{"U1RX":"RD3"},"UART1":{"U1RX":"RD3"}},"users":{"module39":{"mod_name":"UART1"}}},"cname":{"eview":{"dataMap":{"RE5":{"value":"LED1"},"RE6":{"value":"LED2"}}}}}}},"module2":{"scriptId":"@mchp-mcc/pic24-dspic33-interrupt","imports":{"int_16bit_core_v3":{"interfaceId":{"name":"int_16bit_core_v3","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"INTERRUPT CORE"}},"config_bit":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{}},"module64":{"scriptId":"@mchp-mcc/pic24-dspic33-reset","imports":{"rst_sib_v2":{"interfaceId":{"name":"rst_sib_v2","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"RESET"}}},"framewSpecificState":{"userEditedImports":[]}},"module31":{"scriptId":"@mchp-mcc/pic24-dspic33-wdt-upb-v1","imports":{"wdt_upb_16bit_v1":{"interfaceId":{"name":"wdt_upb_16bit_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"WATCHDOG"}},"clock_16bit_interface":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module5","exportId":"clock_16bit_interface"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"scf-adapter/importing:16-bit Bootloader:BootloaderModule":{"scriptId":"scf-adapter/importing:16-bit Bootloader:BootloaderModule","imports":{"boot-cantp-driver":{"interfaceId":{"name":"can-tp","version":"^1"}},"boot-uart-driver":{"interfaceId":{"name":"uart-basic-drv-interface","version":"^1||^2"}},"boot-device-meta":{"interfaceId":{"name":"device-meta-16bit-interface","version":"^1.0"}},"boot-main":{"interfaceId":{"name":"initializer-main","version":"^0.3"}},"boot-code-guard":{"interfaceId":{"name":"code-guard-16bit-interface","version":"^1.0"}},"boot-config-bits":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0"}},"boot-crypto":{"interfaceId":{"name":"crypto-auth-lib","version":"^1.1.0"}},"boot-clock":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0"}},"boot-flash":{"interfaceId":{"name":"flash-interface","version":"^1.0"}},"boot-interrupts":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.1.1-a"}},"boot-dependency-manager":{"interfaceId":{"name":"sort_childToParent","version":"^1"}}},"framewSpecificState":{"userEditedImports":[]}},"module69":{"scriptId":"@mchp-mcc/wdt-16bit-driver","imports":{"wdt_16bit_interface":{"interfaceId":{"name":"wdt-16bit-interface","version":"^1.0.1"},"handle":{"providerId":"module31","exportId":"wdt_16bit_interface"}},"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}}},"framewSpecificState":{"userEditedImports":[]}},"module47":{"scriptId":"@mchp-mcc/pic24-dspic33-nvm-ctrl-16bit-v1","imports":{"nvm_ctrl_16bit_v1":{"interfaceId":{"name":"nvm_ctrl_16bit_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"FLASH"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"interrupt_service":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"scf-adapter/importing:16-bit Bootloader:ApplicationModule":{"scriptId":"scf-adapter/importing:16-bit Bootloader:ApplicationModule","imports":{"boot-device-meta":{"interfaceId":{"name":"device-meta-16bit-interface","version":"^1.0"}},"boot-code-guard":{"interfaceId":{"name":"code-guard-16bit-interface","version":"^1.0"}},"boot-config-bits":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0"}},"boot-clock":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0"}},"boot-flash":{"interfaceId":{"name":"flash-interface","version":"^1.0"}},"boot-interrupts":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.1.1-a"}}},"framewSpecificState":{"userEditedImports":[]}},"module77":{"scriptId":"@mchp-mcc/icd-16bit-driver","imports":{"icd_v7":{"interfaceId":{"name":"icd_v7","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"ICD"}},"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"pin_standard":{"interfaceId":{"name":"pin-standard","version":"^0.1.0"},"handle":{"providerId":"module4","exportId":"pin-standard"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module90":{"scriptId":"@mchp-mcc/uart-driver","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"^1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"uart_basic":{"interfaceId":{"name":"uart-basic","version":"^6.0.0"},"handle":{"providerId":"module39","exportId":"uart_basic","label":"UART1"}}},"framewSpecificState":{"userEditedImports":["uart_basic"]},"payload":{"main":{"software":{"redirectPrintf":true}}}},"module123":{"scriptId":"@mchp-mcc/16bit_data_eeprom_emulation","imports":{"initializer_main":{"interfaceId":{"name":"initializer-main","version":"^0.3.0"},"handle":{"providerId":"module0","exportId":"initializer_main"}},"flash_interface":{"interfaceId":{"name":"flash-interface","version":"^1.3.1"},"handle":{"providerId":"module47","exportId":"flash_interface"}},"project_properties":{"interfaceId":{"name":"project-properties","version":"1.0.1"},"handle":{"providerId":"com.microchip.mcc.melody.adapter.ProjectConfigurationAdapter","exportId":"project-properties"}}},"framewSpecificState":{"userEditedImports":[]}},"module50":{"scriptId":"@mchp-mcc/pic24-dspic33-dmt-upb","imports":{"wdt_dmt_upb_v1":{"interfaceId":{"name":"wdt_dmt_upb_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"DMT"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"interrupt_service":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module82":{"scriptId":"@mchp-mcc/dmt-16bit-driver","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"dmt_16bit_interface":{"interfaceId":{"name":"dmt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module50","exportId":"dmt_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}}},"content":{"@mchp-mcc/pic-16bit":"5.11.2","@mchp-mcc/16bit_data_eeprom_emulation":"2.1.0","@mchp-mcc/wdt-16bit-driver":"1.0.7","@mchp-mcc/clock-16bit-driver":"1.2.1","@mchp-mcc/pic24-dspic33-dmt-upb":"1.1.1","@mchp-mcc/pic24-dspic33-reset":"1.1.0","@mchp-mcc/pic24-dspic33-clock-sib":"1.4.2","@mchp-mcc/dmt-16bit-driver":"1.0.6","@mchp-mcc/main-16bit-manager":"1.1.2","@mchp-mcc/dspic33-configuration-bits":"1.2.2","@mchp-mcc/pin-content-processor":"3.8.0","@mchp-mcc/pic24-dspic33-wdt-upb-v1":"1.2.0","@mchp-mcc/icd-16bit-driver":"1.0.3","@mchp-mcc/pic24-dspic33-interrupt":"1.3.1","@mchp-mcc/pic24-dspic33-nvm-ctrl-16bit-v1":"3.2.1","@mchp-mcc/uart-driver":"1.9.0","@mchp-mcc/pic24-dspic33-pin-manager":"1.3.0","@mchp-mcc/pic24-dspic33-uart-protocol-upb":"1.5.0"}} + + + + + mcc_generated_files\system\watchdog.h + c78d82c6a93f94e2ca7ff8d5a00751d4875fe8f76a564bf5ee672dec7b2fcecd + + + mcc_generated_files\uart\uart1.h + 9d96368e37b8d7696208b70144ee68468bc9dbd10d7b6e280fbb8e32576fb5f7 + + + mcc_generated_files\dee\dee.h + c7604c01517966eb9a640fc7deb5600bd42f358ab134ab62e17ebd8a4648541c + + + mcc_generated_files\system\interrupt.h + 6464b4341a8eaff2e988ffcd845177680e4875f9df99e92bd47057c8ca2f3b10 + + + mcc_generated_files\system\dmt.h + 57d16baa46d9112194e4062405aa45d38de8ed05abc6bc8acbd04d119c2ceaad + + + mcc_generated_files\system\pins.h + 13d66373f1bdcb0bc074eebe59466e1521dfaeacc1a9e171d4888789bdafe188 + + + mcc_generated_files\system\reset_types.h + d191b15996f8e881c5733de5e156e79d7c259fc3fbc8acb2a69a1c66b7492a30 + + + mcc_generated_files\system\interrupt_types.h + fcc4de703d90fc68834c25256201876534d34d74ba76f364853f083b25af5e64 + + + mcc_generated_files\system\src\pins.c + c2b1d073f4adcd5c960f775c72181477f15411b3d8bcaeed8b796a51fcdae533 + + + mcc_generated_files\system\src\dmt.c + 6529950f685b878b2152214e3eb83a956b3f2a12f56ba5b007c0c925ca962203 + + + mcc_generated_files\flash\flash_interface.h + a509b006ad301ebd6295285d4a0019c95a1aad5177225c92d1757b44e40d35cf + + + mcc_generated_files\uart\uart_interface.h + 5ba1f66ca45ceabad47ad42f239110f461a813317896625fae77f75b8e497afe + + + mcc_generated_files\uart\uart_types.h + b2eeabb3cdfd2d14482487bc0dde1a44ad910e074ac930f119ae17a3917c9c25 + + + mcc_generated_files\system\src\clock.c + 13249a24dae8acb448d98503d22c1360ef6c78eeff6a251ec17605d62065dc91 + + + mcc_generated_files\system\clock.h + 4428ec5c7fd48ca6d478a0d10d9e2b6fbd43d8af642d54e2830a70e6f9188edc + + + mcc_generated_files\system\reset.h + 648b2215a7dac788776692bcda2f20dd9806e35bf264bbb985f74affce313a5b + + + mcc_generated_files\flash\flash_types.h + 02f07141ec0ba53f523241cdca2cdd04599fdd80534670ff7ce67efd0f63d6c8 + + + mcc_generated_files\dee\dee_dual_panel.h + c471d3d894c241d8fbbf0777d3aa3b411620d4ff08b8dd5be38f8690bda678b6 + + + mcc_generated_files\dee\src\dee.c + f45c0aee6c8d6ff829cc505ee4729adbf1ca25f3d9cb852ca781ed0ccbf26081 + + + mcc_generated_files\flash\flash_hardware_nonblocking.h + d839bb8ec94215a85a91ae687c8019d749da08ed2924337d176d50729d87c5b9 + + + mcc_generated_files\system\src\reset.c + 90dd98db9464e22649e22e199e8d09d0b9720f6db1cd323c4a8fa956f0586f7b + + + mcc_generated_files\system\system.h + 7452d3b6bf4948ef0e0d63e9e76c5df987903b63b35cc5572be4abb0ae834d15 + + + mcc_generated_files\flash\src\flash_nonblocking.c + 6fc92225cebce64409b1b7b0a9cd26a8b3be7c29030608fdbd4889678cc27211 + + + main.c + bc16a079de30cf6e1f09bbc022097c0021210f08dfc6993e83a1c8b9d8d84ba3 + + + mcc_generated_files\dee\dee_types.h + 174f5e9e9e417c2cb107f530e573a63787b70bd17b77c35a5135186d682b7087 + + + mcc_generated_files\uart\src\uart1.c + 71cce65ed8cc3f7e716f02d3cb2d524eb312e4541e1d0b69efa558e3d3c02b36 + + + mcc_generated_files\flash\src\flash_asm_nonblocking.s + 073e7aab7cdff27a62a55865db2cbf34def0061af0b771717c8e31dade11d6d3 + + + mcc_generated_files\system\src\interrupt.c + 005b73d1475a4935cb8062e3894d4941470c9b405191e2acc729d065a29c0715 + + + mcc_generated_files\system\src\dmt_asm.s + 5627e95412796e39593ab9b1f020a5841f08366fe97dd93bb412bce56643b07c + + + mcc_generated_files\system\src\traps.c + c79aa8c466de788e95471c3a734f4cd2f452b06ba0aa7f0a457bc1c9adefdceb + + + mcc_generated_files\system\src\config_bits.c + 577dce80804428bbf8776cc39716ac3e8f28e5a0badee0d77bb1d11e1c4370ba + + + mcc_generated_files\dee\src\dee_dual_panel.c + ef7b7e1912e4f71015eeafac0d3859501dbfc235ab66c9389e0e7592bd49f08c + + + mcc_generated_files\system\traps.h + 900429a7d683726be69419a799bcdcc8b61c07933d2a0bb76d7abfb097554f74 + + + mcc_generated_files\system\system_types.h + 516f383ecaa24baa7fcc0787fb7897e48562adbaf8b80ce159de37ff831b1287 + + + mcc_generated_files\system\src\system.c + 81c63bff23835a81c9bc017be002fb600b5aa36ba31014b20fa2e90a5c0eeabd + + + mcc_generated_files\flash\flash_nonblocking.h + b4bbd52f06bd27893fe8976dfa3cc1f841a6ca4c1e31507f071fa487b5644d4a + + + \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/main.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/main.c new file mode 100644 index 0000000..9570877 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/main.c @@ -0,0 +1,97 @@ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. + */ +#include "mcc_generated_files/dee/dee.h" +#include "mcc_generated_files/system/system.h" +#include "mcc_generated_files/system/pins.h" +#include "mcc_generated_files/flash/flash_nonblocking.h" +#include + +#define IBSEQ_INDEX 1022 +#define PARTITION2_CONFIG_BITS_START_ADDRESS 0x415F00 +#define PARTITION2_NEW_IBSEQ 0xFFE001 +#define EXPECTED_VALUE_AT_ADDR0 1024 +#define EXPECTED_VALUE_AT_ADDR1 1025 +#define EXPECTED_VALUE_AT_ADDR2 1026 + +void UpdateConfigBitFBTSEQ(); + +volatile bool eraseDone = false; +volatile bool writeDone = false; + +void FlashEraseOpHandler(void* context) { + eraseDone = true; +} + +void FlashProgramOpHandler(void *context) { + writeDone = true; +} + +/* + Main application + */ + +int main(void) { + uint16_t addr0 = 0, addr1 = 1, addr2=2, index; + uint16_t valueAtAddr0 = 0; + uint16_t valueAtAddr1 = 0; + uint16_t valueAtAddr2 = 0; + + SYSTEM_Initialize(); + printf("************* Application in Partition1 starts *******************\r\n"); + DEE_Init(); + for (index = 0; index < 1024; index++) { + DEE_Write(addr0, index + 1); + DEE_Write(addr1, index + 2); + DEE_Write(addr2, index + 3); + } + + DEE_Read(addr0, &valueAtAddr0); + DEE_Read(addr1, &valueAtAddr1); + DEE_Read(addr2, &valueAtAddr2); + + /*Update the partition2 FBTSEQ config bit so that after reboot partition2 becomes active partition*/ + UpdateConfigBitFBTSEQ(); + + if (valueAtAddr0 == EXPECTED_VALUE_AT_ADDR0 && valueAtAddr1 == EXPECTED_VALUE_AT_ADDR1 && valueAtAddr2 == EXPECTED_VALUE_AT_ADDR2) { + LED2_SetHigh(); + printf("Data EEPROM Emulation successful.\r\n Value at address 0 is %d\r\n Value at address 1 is %d\r\n Value at address 2 is %d\r\n", valueAtAddr0, valueAtAddr1, valueAtAddr2); + } else { + printf("Data EEPROM Emulation failed.\r\n Value at address 0 is %d\r\n Value at address 1 is %d\r\n Value at address 2 is %d\r\n", valueAtAddr0, valueAtAddr1, valueAtAddr2); + } + printf("************* Application in Partition1 ends *******************\r\n"); + while (1); +} + +void UpdateConfigBitFBTSEQ() { + int index = 0; + flash_data_t data[FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS] = {0x00}; + flash_adr_t confAddress = flash.PageAddressGet(PARTITION2_CONFIG_BITS_START_ADDRESS); + flash.NonBlockingRead(confAddress, FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS, data); + flash.NonBlockingPageErase(confAddress, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while (eraseDone == false); + data[IBSEQ_INDEX] = PARTITION2_NEW_IBSEQ; + while (index < FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS) { + flash.NonBlockingRowWrite(confAddress, &data[index], FLASH_UNLOCK_KEY, FlashProgramOpHandler, NULL); + while (flash.OperationStatusGet() == FLASH_OP_BUSY); + index = index + FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS; + confAddress = confAddress + FLASH_WRITE_ROW_SIZE_IN_PC_UNITS; + } +} \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee.h new file mode 100644 index 0000000..e98cade --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee.h @@ -0,0 +1,105 @@ +/** + DEE Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + dee.h + + @Summary + This is the generated header file for the DEE library using Melody Code Configurator + + @Description + This header file provides APIs for library DEE. + The generated drivers are tested against the following: +*/ + +#ifndef DEE_H +#define DEE_H + +#include +#include + +typedef enum{ + DEE_NO_ERROR, + DEE_EXPIRED_PAGE, + DEE_PACK_BEFORE_PAGE_FULL, + DEE_PACK_BEFORE_INIT, + DEE_PACK_SKIPPED, + DEE_ILLEGAL_ADDRESS, + DEE_PAGE_CORRUPT, + DEE_WRITE_ERROR, + DEE_READ_ERROR, +}DEE_RETURN_STATUS; + + +/** + @Summary + This function initializes all of the EEPROM banks + + @Description + This routine finds an unexpired page to become an active page. It then + counts the number of active pages. If no active pages are found, the + first unexpired page is initialized for emulation. If one active page is + found, it is assumes a reset occurred and the function does nothing. If + two active pages are found, it is assumes a reset occurred during a pack. + The second page is erased and a pack is called. If three, an error code + is returned as the allocated memory is assumed to be corrupted. This + function must be called prior to any other operation. + + @Param + None. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_Init(void); + +/** + @Summary + This function is used to retrieve data EEPROM information. + + @Description + This routine verifies the address is valid. If not, the Illegal Address + flag is set and return DEE_ILLEGAL_ADDRESS. It then finds the active page,if an + active page can not be found, the Page Corrupt status bit is set and + DEE_PAGE_CORRUPT is returned. A reverse search of the active page attempts to find + the matching address in the program memory MSB (odd address). If a match + is found, the corresponding data EEPROM data (even address) is returned, + otherwise DEE_READ_ERROR is returned. This function can be called by the user. + + @Param + Data EE address and pointer to hold the read flash data. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_Read(uint16_t address, uint16_t *data); + +/** + @Summary + This function is used to write emulated data EEPROM. + + @Description + This routine verifies the address is valid. If not, the Illegal Address + flag is set and an error code is returned. It then finds the active page. + If an active page can not be found, the Page Corrupt status bit is set + and an error code is returned. A read is performed, if the data was not + changed, the function exits. If the last location is programmed, the Pack + Skipped error flag is set (one location should always be available). The + data EE information (MSB = address, LSW = data) is programmed and + verified. If the verify fails, the Write Error flag is set. If the write + went into the last location of the page, pack is called. This function + can be called by the user. + + @Param + Data EE address and data to be written. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_Write(uint16_t address, uint16_t data); + + +#endif /* DEE_H */ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee_dual_panel.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee_dual_panel.h new file mode 100644 index 0000000..9a23fca --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee_dual_panel.h @@ -0,0 +1,55 @@ +/** + DEE Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + dee_helper.h + + @Summary + This is the generated header file for the DEE library using Melody Code Configurator + + @Description + This header file provides APIs for library DEE. + The generated drivers are tested against the following: +*/ + +#ifndef DEE_HELPER_H +#define DEE_HELPER_H + +#include "dee.h" + +/** + @Summary + This function initializes all of the EEPROM banks + + @Description + This functions performs the same functionality as DEE_Init() , but this function works on the + active partition in devices with dual partition support. + + @Param + None. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_ActivePartitionInit(void); + +/** + @Summary + This function copies the DEE data from active partition to in-active partition + + @Description + This function initializes the DEE data structure in the active partition and check if there is any data available + in the active partition from the previous execution if so it copies the data to the inactive partition. + + @Param + None. + + @Returns + Returns True or False. +*/ +bool DEE_ActiveToInactivePartitionDataCopy(void); + +#endif /* DEE_HELPER_H */ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee_types.h new file mode 100644 index 0000000..5b33ed8 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/dee_types.h @@ -0,0 +1,93 @@ +/** + DEE Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + dee_types.h + + @Summary + This is the generated header file for the DEE library using Melody Code Configurator + + @Description + This header file provides APIs for library DEE. + The generated drivers are tested against the following: +*/ + +#ifndef DEE_TYPES_H +#define DEE_TYPES_H + +#define DATA_EE_BANKS 1 +#define DATA_EE_SIZE 255 +#define DATA_EE_TOTAL_SIZE (DATA_EE_BANKS * DATA_EE_SIZE) +#define NUM_DATA_EE_PAGES 2 +#define NUMBER_OF_INSTRUCTIONS_IN_PAGE 1024 +#define NUMBER_OF_INSTRUCTIONS_IN_ROW 128 +// If the device has ECC +#define __HAS_ECC 1 +#define ERASE_WRITE_CYCLE_MAX 10000 +#define NUMBER_OF_ROWS_IN_PAGE (_FLASH_PAGE / _FLASH_ROW) +#define PAGE_AVAILABLE 1 +#define PAGE_CURRENT 0 +#define PAGE_EXPIRED 0 +#define PAGE_NOT_AVAILABLE 0 +#define PAGE_NOT_CURRENT 1 +#define PAGE_NOT_EXPIRED 1 +#define STATUS_AVAILABLE 18 +#define STATUS_CURRENT 19 +#define STATUS_EXPIRED 20 +#define ERASE_STATE 0xFFFFFF +#define DEE_STATUS_MASK 0xE3 +#define PACKED_PAGE_DATA_SIZE 0x100 +#define MAX_DATA_SIZE_PER_PAGE 0xFF +#define DEE_ADDRESS_MASK 0x00FF0000 +#define WRITE_RETRY_COUNT 2 +#define FLASH_WORD_WRITE_SIZE 2 +#define DEE_START_ADDRESS_INACTIVE_PARTITION 0x414800 +#define DEE_START_ADDRESS_ACTIVE_PARTITION 0x14800 + +/*Data EE info stored in PM in following format + Status in first two locations of PM page, + 8-bit DEE Address (odd address, low byte) 16-bit DEE data (even address)*/ +#define BYTES_PER_DATA_EE 2 +#define DEE_BANK_SIZE (NUMBER_OF_INSTRUCTIONS_IN_PAGE * BYTES_PER_DATA_EE * NUM_DATA_EE_PAGES) +#define DEE_PAGE_SIZE (NUMBER_OF_INSTRUCTIONS_IN_PAGE * BYTES_PER_DATA_EE) +#define DEE_DATA_SIZE_IN_BYTES (DATA_EE_BANKS * NUM_DATA_EE_PAGES * NUMBER_OF_INSTRUCTIONS_IN_PAGE * BYTES_PER_DATA_EE) + + +typedef union +{ + uint8_t val; + struct + { + unsigned addrNotFound:1; + unsigned expiredPage:1; + unsigned packBeforePageFull:1; + unsigned packBeforeInit:1; + unsigned packSkipped:1; + unsigned IllegalAddress:1; + unsigned pageCorrupt:1; + unsigned writeError:1; + }; +} DATA_EE_FLAGS; + + +// User constant validation +#if DATA_EE_BANKS == 0 + #error Minimum data EE banks is 1 +#endif + +#if DATA_EE_SIZE > 255 + #error Maximum data EE size is 255 +#endif + +#if NUM_DATA_EE_PAGES < 2 + #error Minimum number of program memory pages is 2 +#endif + +#if ERASE_WRITE_CYCLE_MAX > 65535 + #error Maximum number of erase/write cycles is 65,535 +#endif + +#endif /* DEE_TYPES_H */ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/src/dee.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/src/dee.c new file mode 100644 index 0000000..8a246a8 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/src/dee.c @@ -0,0 +1,582 @@ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include +#include "../../flash/flash_nonblocking.h" +#include "../dee.h" +#include "../dee_types.h" +#include "../dee_dual_panel.h" + +/*Data EE info stored in PM in following format + Status in first two locations of PM page, + 8-bit DEE Address (odd address, low byte) 16-bit DEE data (even address)*/ +uint8_t emulationPages[DEE_DATA_SIZE_IN_BYTES] + __attribute__ ((space(psv), address(DEE_START_ADDRESS_INACTIVE_PARTITION), aligned(NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2), noload)); +#define DEE_PAGE_ADDRESS(bank, page) ((__builtin_tbladdress(&emulationPages) + (DEE_BANK_SIZE * (bank)) + (DEE_PAGE_SIZE * (page))) & 0xFFFFFF) + +#define GetAddrNotFound() dataEEFlags.addrNotFound +#define SetAddrNotFound(x) dataEEFlags.addrNotFound = x +#define GetPageCorruptStatus() dataEEFlags.pageCorrupt +#define SetPageCorruptStatus(x) dataEEFlags.pageCorrupt = x +#define GetPageExpiredPage() dataEEFlags.expiredPage +#define SetPageExpiredPage(x) dataEEFlags.expiredPage = x +#define GetPageIllegalAddress() dataEEFlags.IllegalAddress +#define SetPageIllegalAddress(x) dataEEFlags.IllegalAddress = x +#define GetPagePackBeforeInit() dataEEFlags.packBeforeInit +#define SetPagePackBeforeInit(x) dataEEFlags.packBeforeInit = x +#define GetPagePackBeforePageFull() dataEEFlags.packBeforePageFull +#define SetPagePackBeforePageFull(x) dataEEFlags.packBeforePageFull = x +#define GetPagePackSkipped() dataEEFlags.packSkipped +#define SetPagePackSkipped(x) dataEEFlags.packSkipped = x +#define GetPageWriteError() dataEEFlags.writeError +#define SetPageWriteError(x) dataEEFlags.writeError = x + +DATA_EE_FLAGS dataEEFlags; + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field); +static void ErasePage(uint8_t bank, uint8_t page); +static uint16_t GetNextAvailCount(uint8_t bank); +static DEE_RETURN_STATUS DEE_Pack(uint8_t bank); +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey); +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data); +static DEE_RETURN_STATUS DEE_Initialize(void); + +static void FlashEraseOpHandler(void* context) { + // Doing nothing +} + +static void FlashProgramOpHandler(void *context) { + // Doing nothing +} + +DEE_RETURN_STATUS DEE_Init(void) +{ + DEE_RETURN_STATUS deeReturnStatus = DEE_NO_ERROR; + deeReturnStatus = DEE_ActivePartitionInit(); + if(deeReturnStatus == DEE_NO_ERROR) + { + bool dataCopied = DEE_ActiveToInactivePartitionDataCopy(); + if(!dataCopied) + { + deeReturnStatus = DEE_Initialize(); + } + } + return deeReturnStatus; +} + +DEE_RETURN_STATUS DEE_Initialize(void) +{ + uint8_t pageCnt; + uint16_t erasePage; + uint16_t currentPage; + uint32_t pageAddress; + uint8_t bank; + uint32_t statusWord[2]; + + dataEEFlags.val = 0; + for (bank = 0; bank < DATA_EE_BANKS; bank++) + { + pageCnt = 0; + erasePage = 0; + + // Find unexpired page + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_EXPIRED) == PAGE_EXPIRED); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - All pages expired + } + // Count active page(s). + for (currentPage = 0; currentPage < NUM_DATA_EE_PAGES; currentPage++) + { + if (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_CURRENT) + { + pageCnt++; + } + } + //If no active pages found, initialize page 0 + if (pageCnt == 0) + { + ErasePage(bank, 0); + pageAddress = DEE_PAGE_ADDRESS(bank, 0); + //New page: unavailable, active, reset count + statusWord[0] = 0xF3; + statusWord[0] = statusWord[0] << 16; + statusWord[1] = ERASE_STATE; + DEE_FlashWrite(pageAddress, statusWord, FLASH_UNLOCK_KEY); + continue; + } + //If one active page, do nothing + else if (pageCnt == 1) + { + continue; + } + //If two active pages, erase second and repack first + else if (pageCnt == 2) + { + if ((GetPageStatus(bank, NUM_DATA_EE_PAGES - 1, STATUS_CURRENT) == PAGE_CURRENT) && + (GetPageStatus(bank, 0, STATUS_CURRENT) == PAGE_CURRENT)) + { + currentPage = NUM_DATA_EE_PAGES - 1; + erasePage = 0; + } + else + { + currentPage = 0; + while ((GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT) && + (currentPage < NUM_DATA_EE_PAGES)) + { + currentPage++; + } + erasePage = currentPage + 1; + if (erasePage == NUM_DATA_EE_PAGES) + { + erasePage = 0; + } + } + ErasePage(bank, erasePage); + if (!GetNextAvailCount(bank)) + { + DEE_Pack(bank); + } + continue; + } + else + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); + } + } + return (DEE_NO_ERROR); +} + +DEE_RETURN_STATUS DEE_Read(uint16_t addr, uint16_t* dataRead) +{ + uint16_t currentPage; + uint32_t pageAddress; + uint8_t latchAddr; + uint16_t i; + uint8_t bank; + uint32_t latchAddrData; + + if (addr >= DATA_EE_TOTAL_SIZE) + { + SetPageIllegalAddress(1); + return (DEE_ILLEGAL_ADDRESS); + } + + bank = addr / DATA_EE_SIZE; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); // Error - no active page + } + + pageAddress = DEE_PAGE_ADDRESS(bank, (currentPage + 1)) - 4; + + i = NUMBER_OF_INSTRUCTIONS_IN_PAGE; + + do + { + DEE_FlashRead(pageAddress, 1, &latchAddrData); + latchAddr = (latchAddrData >> 16) & 0xFF; + pageAddress -= 4; // Skip over preceding odd address in devices with ECC or double word writes + i -= 2; + } + while ((i > 0) && (latchAddr != (addr % DATA_EE_SIZE))); + + if (!i) + { + SetAddrNotFound(1); + return (DEE_ILLEGAL_ADDRESS); + } + + pageAddress += 4; // Adjust offset to skip the odd word + + DEE_FlashRead(pageAddress, 1, &latchAddrData); + //Extract the data(lower 16 bits) + *dataRead = latchAddrData & 0xFFFF; + return (DEE_NO_ERROR); +} + +DEE_RETURN_STATUS DEE_Write(uint16_t addr, uint16_t data) +{ + uint16_t currentPage; + uint32_t pageAddress; //Current array (page) offset of selected element (PM 16-bit word) + uint16_t nextLoc; + volatile uint16_t latchData; + volatile uint8_t latchAddr; + uint8_t dataEEFlags_sh; + uint16_t bank; + uint16_t pageToBeErased; + uint32_t deeItem[2]; + + if (addr >= DATA_EE_TOTAL_SIZE) + { + SetPageIllegalAddress(1); + return (DEE_ILLEGAL_ADDRESS); + } + + bank = addr / DATA_EE_SIZE; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); // Error - no active page + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + + nextLoc = GetNextAvailCount(bank); + + if (!nextLoc) + { + pageToBeErased = currentPage + 1; + if(pageToBeErased == NUM_DATA_EE_PAGES) + { + pageToBeErased = 0; + } + ErasePage(bank, pageToBeErased); + DEE_Pack(bank); + + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); // Error - no active page + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + nextLoc = GetNextAvailCount(bank); + } + + dataEEFlags_sh = dataEEFlags.val; + //Do not write data if it did not change + uint16_t dataRead; + DEE_Read(addr, &dataRead); + if (dataRead == data) + { + if (GetAddrNotFound() == 0) // Check if the read was successful + { + dataEEFlags.val = dataEEFlags_sh; + return (DEE_NO_ERROR); + } + } + dataEEFlags.val = dataEEFlags_sh; //Restore status flags + + pageAddress = pageAddress + nextLoc; + + deeItem[0] = addr % DATA_EE_SIZE; + deeItem[0] = (deeItem[0] << 16) | data; + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(pageAddress, deeItem, FLASH_UNLOCK_KEY); + + Nop(); + Nop(); + + DEE_FlashRead(pageAddress, 1, &deeItem[0]); + latchData = (deeItem[0] & 0xFFFF); + + if (latchData != (data & 0xFFFF)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - RAM does not match PM + } + + latchAddr = ((deeItem[0] >> 16) & 0xFF); + + if (latchAddr != (addr % DATA_EE_SIZE)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - RAM does not match PM + } + + //Pack if page is full + if ((nextLoc + 4) == ((NUMBER_OF_INSTRUCTIONS_IN_PAGE) * 2)) + { + DEE_Pack(bank); + } + + return (DEE_NO_ERROR); +} + +static DEE_RETURN_STATUS DEE_Pack(uint8_t bank) +{ + uint16_t currentPage; //Array row (PM page) of active DEE page + uint16_t packedPage; //Array row (PM page) of packed page + uint32_t currentPageAddress; //Current page address + uint32_t packedPageAddress; //Packed page address + uint16_t latchAddr; + uint16_t latchData; + uint8_t dataEEFlags_sh; + uint32_t deeItem[2]; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPagePackBeforeInit(1); + return (DEE_PACK_BEFORE_INIT); // Error - no active page + } + else + { + // Find the next unexpired page to use + packedPage = currentPage + 1; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + while (GetPageStatus(bank, packedPage, STATUS_EXPIRED) == PAGE_EXPIRED) + { + packedPage++; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + if (packedPage == currentPage) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - all pages expired + } + } + } + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + if (GetNextAvailCount(bank)) + { + SetPagePackBeforePageFull(1); // Pack called before the page was full + } + + dataEEFlags_sh = dataEEFlags.val; + SetAddrNotFound(0); // Initialize flag + + + deeItem[0] = ERASE_STATE; + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on dsPIC33E devices with ECC or double word writes + latchAddr = 0; + + do + { + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &latchData); + if (GetAddrNotFound()) //if address is unwritten, skip to next address + { + SetAddrNotFound(0); + } + else + { + deeItem[0] = latchAddr; + deeItem[0] = ((deeItem[0] << 16) | (latchData & 0xFFFF)); + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + latchAddr++; + } + while (latchAddr != DATA_EE_SIZE); + + dataEEFlags.val = dataEEFlags_sh; //Restore status flags + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage) + 4; // Adjust offset to skip the odd word + + uint32_t data; + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + + while (latchAddr != 0xFF) + { + uint16_t dataRead; + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &dataRead); + if (dataRead != latchData) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - data does not match + } + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) &0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + + //Program page status + currentPageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + DEE_FlashRead(currentPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + + if (packedPage == 0) + { + latchData++; //Increment E/W counter + } + + if (latchData >= ERASE_WRITE_CYCLE_MAX - 1) + { + SetPageExpiredPage(1); + latchAddr &= 0xEF; + } + + uint32_t dataItem[2]; + dataItem[0] = latchAddr; + dataItem[0] = (dataItem[0] << 16) | latchData; + dataItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, dataItem, FLASH_UNLOCK_KEY); + DEE_FlashRead(packedPageAddress, 1, &data); + uint16_t readAddr = (data >> 16) & 0xFF; + uint16_t readData = data & 0xFFFF; + + if ((latchAddr != readAddr) || + (latchData != readData)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); + } + + //Erase active page + ErasePage(bank, currentPage); + + return (GetPageExpiredPage()); +} + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field) +{ + uint32_t pageAddress; + uint8_t statusByte; + uint8_t status; + uint32_t statusInfo; + + pageAddress = DEE_PAGE_ADDRESS(bank, page); + DEE_FlashRead(pageAddress, 1, &statusInfo); + statusByte = statusInfo >> 16 & 0xFF; + switch (field) + { + case STATUS_AVAILABLE: + status = ((statusByte & 4) >> 2); + break; + case STATUS_CURRENT: + status = ((statusByte & 8) >> 3); + break; + case STATUS_EXPIRED: + status = ((statusByte & 16) >> 4); + break; + default: + status = 0; + break; + } + return (status); +} + +static void ErasePage(uint8_t bank, uint8_t page) +{ + uint32_t pageAddress = DEE_PAGE_ADDRESS(bank, page); + FLASH_NonBlockingPageErase(pageAddress, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); + return; +} + +static uint16_t GetNextAvailCount(uint8_t bank) +{ + uint16_t nextAvailCount = 0; + uint16_t currentPage; + uint8_t dataEEval; + uint32_t pageAddress; + uint32_t latchAddrData; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + + do + { + nextAvailCount += 4; + pageAddress += 4; + DEE_FlashRead(pageAddress, 1, &latchAddrData); + dataEEval = (latchAddrData >> 16) & 0xFF; + } + while ((nextAvailCount < NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) && (dataEEval != 0xFF)); + + if (nextAvailCount == NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) + { + nextAvailCount = 0; + } + return (nextAvailCount); +} + +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey) +{ + FLASH_NonBlockingWordWrite(flashAddress, data, unlockKey, FlashProgramOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); +} + +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data) +{ + while(FLASH_NonBlockingRead(flashAddress, count, data) == FLASH_OP_BUSY); +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/src/dee_dual_panel.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/src/dee_dual_panel.c new file mode 100644 index 0000000..4d21f58 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/dee/src/dee_dual_panel.c @@ -0,0 +1,532 @@ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include +#include "../../flash/flash_nonblocking.h" +#include "../dee.h" +#include "../dee_types.h" + +/*Data EE info stored in PM in following format + Status in first two locations of PM page, + 8-bit DEE Address (odd address, low byte) 16-bit DEE data (even address)*/ +uint8_t activePartitionEmulationPages[DEE_DATA_SIZE_IN_BYTES] + __attribute__ ((space(psv), address(DEE_START_ADDRESS_ACTIVE_PARTITION), aligned(NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2), noload)); +#define DEE_PAGE_ADDRESS(bank, page) ((__builtin_tbladdress(&activePartitionEmulationPages) + (DEE_BANK_SIZE * (bank)) + (DEE_PAGE_SIZE * (page))) & 0xFFFFFF) + +#define GetAddrNotFound() activePartitionDataEEFlags.addrNotFound +#define SetAddrNotFound(x) activePartitionDataEEFlags.addrNotFound = x +#define GetPageCorruptStatus() activePartitionDataEEFlags.pageCorrupt +#define SetPageCorruptStatus(x) activePartitionDataEEFlags.pageCorrupt = x +#define GetPageExpiredPage() activePartitionDataEEFlags.expiredPage +#define SetPageExpiredPage(x) activePartitionDataEEFlags.expiredPage = x +#define GetPageIllegalAddress() activePartitionDataEEFlags.IllegalAddress +#define SetPageIllegalAddress(x) activePartitionDataEEFlags.IllegalAddress = x +#define GetPagePackBeforeInit() activePartitionDataEEFlags.packBeforeInit +#define SetPagePackBeforeInit(x) activePartitionDataEEFlags.packBeforeInit = x +#define GetPagePackBeforePageFull() activePartitionDataEEFlags.packBeforePageFull +#define SetPagePackBeforePageFull(x) activePartitionDataEEFlags.packBeforePageFull = x +#define GetPagePackSkipped() activePartitionDataEEFlags.packSkipped +#define SetPagePackSkipped(x) activePartitionDataEEFlags.packSkipped = x +#define GetPageWriteError() activePartitionDataEEFlags.writeError +#define SetPageWriteError(x) activePartitionDataEEFlags.writeError = x + +DATA_EE_FLAGS activePartitionDataEEFlags; + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field); +static void ErasePage(uint8_t bank, uint8_t page); +static uint16_t GetNextAvailCount(uint8_t bank); +static DEE_RETURN_STATUS DEE_ActivePartitionPack(uint8_t bank); +static bool DEE_IsDataCopyRequired(); +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey); +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data); +static void DEE_RetryDataWrite(flash_adr_t destAddr, flash_data_t *packedPageData); +static void DEE_PackedDataGet(flash_data_t *fullPageData, uint32_t fullPageDataSize, flash_data_t *packedPageData); + +static void FlashEraseOpHandler(void* context) { + // Doing nothing +} + +static void FlashProgramOpHandler(void *context) { + // Doing nothing +} + + +DEE_RETURN_STATUS DEE_ActivePartitionInit(void) +{ + uint8_t pageCnt; + uint16_t erasePage; + uint16_t currentPage; + uint32_t pageAddress; + uint8_t bank; + uint32_t statusWord[2]; + + activePartitionDataEEFlags.val = 0; + for (bank = 0; bank < DATA_EE_BANKS; bank++) + { + pageCnt = 0; + erasePage = 0; + + // Find unexpired page + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_EXPIRED) == PAGE_EXPIRED); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - All pages expired + } + // Count active page(s). + for (currentPage = 0; currentPage < NUM_DATA_EE_PAGES; currentPage++) + { + if (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_CURRENT) + { + pageCnt++; + } + } + //If no active pages found, initialize page 0 + if (pageCnt == 0) + { + ErasePage(bank, 0); + pageAddress = DEE_PAGE_ADDRESS(bank, 0); + //New page: unavailable, active, reset count + statusWord[0] = 0xF3; + statusWord[0] = statusWord[0] << 16; + statusWord[1] = ERASE_STATE; + DEE_FlashWrite(pageAddress, statusWord, FLASH_UNLOCK_KEY); + continue; + } + //If one active page, do nothing + else if (pageCnt == 1) + { + continue; + } + //If two active pages, erase second and repack first + else if (pageCnt == 2) + { + if ((GetPageStatus(bank, NUM_DATA_EE_PAGES - 1, STATUS_CURRENT) == PAGE_CURRENT) && + (GetPageStatus(bank, 0, STATUS_CURRENT) == PAGE_CURRENT)) + { + currentPage = NUM_DATA_EE_PAGES - 1; + erasePage = 0; + } + else + { + currentPage = 0; + while ((GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT) && + (currentPage < NUM_DATA_EE_PAGES)) + { + currentPage++; + } + erasePage = currentPage + 1; + if (erasePage == NUM_DATA_EE_PAGES) + { + erasePage = 0; + } + } + ErasePage(bank, erasePage); + if (!GetNextAvailCount(bank)) + { + DEE_ActivePartitionPack(bank); + } + continue; + } + else + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); + } + } + return (DEE_NO_ERROR); +} + +static DEE_RETURN_STATUS DEE_ActivePartitionPack(uint8_t bank) +{ + uint16_t currentPage; //Array row (PM page) of active DEE page + uint16_t packedPage; //Array row (PM page) of packed page + uint32_t currentPageAddress; //Current page address + uint32_t packedPageAddress; //Packed page address + uint16_t latchAddr; + uint16_t latchData; + uint8_t dataEEFlags_sh; + uint32_t deeItem[2]; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPagePackBeforeInit(1); + return (DEE_PACK_BEFORE_INIT); // Error - no active page + } + else + { + // Find the next unexpired page to use + packedPage = currentPage + 1; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + while (GetPageStatus(bank, packedPage, STATUS_EXPIRED) == PAGE_EXPIRED) + { + packedPage++; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + if (packedPage == currentPage) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - all pages expired + } + } + } + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + if (GetNextAvailCount(bank)) + { + SetPagePackBeforePageFull(1); // Pack called before the page was full + } + + dataEEFlags_sh = activePartitionDataEEFlags.val; + SetAddrNotFound(0); // Initialize flag + + + deeItem[0] = ERASE_STATE; + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on dsPIC33E devices with ECC or double word writes + latchAddr = 0; + + do + { + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &latchData); + if (GetAddrNotFound()) //if address is unwritten, skip to next address + { + SetAddrNotFound(0); + } + else + { + deeItem[0] = latchAddr; + deeItem[0] = ((deeItem[0] << 16) | (latchData & 0xFFFF)); + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + latchAddr++; + } + while (latchAddr != DATA_EE_SIZE); + + activePartitionDataEEFlags.val = dataEEFlags_sh; //Restore status flags + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage) + 4; // Adjust offset to skip the odd word + + uint32_t data; + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + + while (latchAddr != 0xFF) + { + uint16_t dataRead; + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &dataRead); + if (dataRead != latchData) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - data does not match + } + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) &0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + + //Program page status + currentPageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + DEE_FlashRead(currentPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + + if (packedPage == 0) + { + latchData++; //Increment E/W counter + } + + if (latchData >= ERASE_WRITE_CYCLE_MAX - 1) + { + SetPageExpiredPage(1); + latchAddr &= 0xEF; + } + + uint32_t dataItem[2]; + dataItem[0] = latchAddr; + dataItem[0] = (dataItem[0] << 16) | latchData; + dataItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, dataItem, FLASH_UNLOCK_KEY); + DEE_FlashRead(packedPageAddress, 1, &data); + uint16_t readAddr = (data >> 16) & 0xFF; + uint16_t readData = data & 0xFFFF; + + if ((latchAddr != readAddr) || + (latchData != readData)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); + } + + //Erase active page + ErasePage(bank, currentPage); + + return (GetPageExpiredPage()); +} + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field) +{ + uint32_t pageAddress; + uint8_t statusByte; + uint8_t status; + uint32_t statusInfo; + + pageAddress = DEE_PAGE_ADDRESS(bank, page); + DEE_FlashRead(pageAddress, 1, &statusInfo); + statusByte = statusInfo >> 16 & 0xFF; + switch (field) + { + case STATUS_AVAILABLE: + status = ((statusByte & 4) >> 2); + break; + case STATUS_CURRENT: + status = ((statusByte & 8) >> 3); + break; + case STATUS_EXPIRED: + status = ((statusByte & 16) >> 4); + break; + default: + status = 0; + break; + } + return (status); +} + +static void ErasePage(uint8_t bank, uint8_t page) +{ + uint32_t pageAddress = DEE_PAGE_ADDRESS(bank, page); + FLASH_NonBlockingPageErase(pageAddress, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); + return; +} + +static uint16_t GetNextAvailCount(uint8_t bank) +{ + uint16_t nextAvailCount = 0; + uint16_t currentPage; + uint8_t dataEEval; + uint32_t pageAddress; + uint32_t latchAddrData; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + + do + { + nextAvailCount += 4; + pageAddress += 4; + DEE_FlashRead(pageAddress, 1, &latchAddrData); + dataEEval = (latchAddrData >> 16) & 0xFF; + } + while ((nextAvailCount < NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) && (dataEEval != 0xFF)); + + if (nextAvailCount == NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) + { + nextAvailCount = 0; + } + return (nextAvailCount); +} + +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey) +{ + FLASH_NonBlockingWordWrite(flashAddress, data, unlockKey, FlashProgramOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); +} + +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data) +{ + while(FLASH_NonBlockingRead(flashAddress, count, data) == FLASH_OP_BUSY); +} + +bool DEE_ActiveToInactivePartitionDataCopy() +{ + bool dataCopied = false; + uint16_t index = 0; + uint16_t numberOfPagesCopied = 0; + uint32_t dataInActivePartition; + uint32_t dataInInactivePartition; + flash_adr_t srcAddr = DEE_START_ADDRESS_ACTIVE_PARTITION; + flash_adr_t dstAddr = DEE_START_ADDRESS_INACTIVE_PARTITION; + //Check for status word at the start address of each page , if found copy is required + bool copyRequired = DEE_IsDataCopyRequired(); + if (copyRequired) + { + while (numberOfPagesCopied < (DATA_EE_BANKS * NUM_DATA_EE_PAGES)) + { + DEE_FlashRead(srcAddr, 1, &dataInActivePartition); + // Pages with data , copy data to other partition + if (((dataInActivePartition & ERASE_STATE) != ERASE_STATE)) + { + /* Declare arrays for holding the entire page data and packed page data */ + flash_data_t fullPageData[FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS]; + flash_data_t packedPageData[PACKED_PAGE_DATA_SIZE * FLASH_WORD_WRITE_SIZE]; + flash_data_t pageStatus[2]; + /* Initialize the arrays to 0xFFFFFFFF */ + memset(fullPageData, 0xFF, FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS * sizeof(flash_data_t)); + memset(packedPageData, 0xFF, PACKED_PAGE_DATA_SIZE * FLASH_WORD_WRITE_SIZE * sizeof(flash_data_t)); + /* Read entire page and pack the page*/ + DEE_FlashRead(srcAddr, FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS , fullPageData); + DEE_PackedDataGet(fullPageData, FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS, packedPageData); + /*Erase the destination page */ + FLASH_NonBlockingPageErase(dstAddr, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + /*Program the destination page with packed data */ + index = 0; + flash_adr_t tempDestAddr = dstAddr; + while (index < (PACKED_PAGE_DATA_SIZE * FLASH_WORD_WRITE_SIZE)) + { + FLASH_NonBlockingRowWrite(tempDestAddr, &packedPageData[index], FLASH_UNLOCK_KEY, FlashProgramOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + /* Retry write in case of any write error */ + if(FLASH_OperationStatusGet() == FLASH_WRITE_ERROR) + { + DEE_RetryDataWrite(tempDestAddr, &packedPageData[index]); + } + index = index + NUMBER_OF_INSTRUCTIONS_IN_ROW; + tempDestAddr = tempDestAddr + FLASH_WRITE_ROW_SIZE_IN_PC_UNITS; + } + /* copy page status from active partition page to inactive partition page */ + pageStatus[0] = fullPageData[0]; + pageStatus[1] = ERASE_STATE; + DEE_FlashWrite(dstAddr, pageStatus, FLASH_UNLOCK_KEY); + + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + dstAddr = dstAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + dataCopied = true; + } + else + { + /* Check if there is any valid DEE data , this condition occurs when the data copied correctly + during the previous reboot , but there was some issue while erasing the page i.e. some pages are + erased and some are not */ + + DEE_FlashRead(dstAddr, 1, &dataInInactivePartition); + if ((dataInInactivePartition & ERASE_STATE) == ERASE_STATE) + { + FLASH_NonBlockingPageErase(dstAddr, FLASH_UNLOCK_KEY, FlashEraseOpHandler , NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + } + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + dstAddr = dstAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + } + numberOfPagesCopied++; + } + /* Delete data from the active partition */ + if (dataCopied) { + srcAddr = DEE_START_ADDRESS_ACTIVE_PARTITION; + for (index = 0; index < numberOfPagesCopied; index++) { + FLASH_NonBlockingPageErase(srcAddr, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + } + } + + } + return dataCopied; +} + +bool DEE_IsDataCopyRequired() +{ + bool copyRequired = false; + uint16_t numberOfPagesChecked = 0; + uint32_t dataInActivePartition; + flash_adr_t srcAddr = DEE_START_ADDRESS_ACTIVE_PARTITION; + while (numberOfPagesChecked < (DATA_EE_BANKS * NUM_DATA_EE_PAGES)) + { + /* Check whether data is present at address immediately after the page status */ + DEE_FlashRead(srcAddr + 4, 1, &dataInActivePartition); + if ((dataInActivePartition & ERASE_STATE) != ERASE_STATE) + { + copyRequired = true; + break; + } + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + numberOfPagesChecked++; + } + return copyRequired; +} + +static void DEE_PackedDataGet(flash_data_t *fullPageData, uint32_t fullPageDataSize, flash_data_t *packedPageData) +{ + uint8_t deeAddress = MAX_DATA_SIZE_PER_PAGE; + uint32_t exists[MAX_DATA_SIZE_PER_PAGE] = {0}; + uint32_t packedDataIndex = FLASH_WORD_WRITE_SIZE; + for(int32_t index = fullPageDataSize - 1; index >= FLASH_WORD_WRITE_SIZE; index--) + { + deeAddress = (fullPageData[index] & DEE_ADDRESS_MASK) >> 16; + if(!exists[deeAddress] && deeAddress != MAX_DATA_SIZE_PER_PAGE) + { + packedPageData[packedDataIndex] = fullPageData[index]; + packedDataIndex = packedDataIndex + FLASH_WORD_WRITE_SIZE; + exists[deeAddress] = 1; + } + } +} + +static void DEE_RetryDataWrite(flash_adr_t destAddr, flash_data_t *packedPageData) { + uint16_t retryIndex = 0; + for (retryIndex = 0; retryIndex < WRITE_RETRY_COUNT; retryIndex++) { + FLASH_NonBlockingRowWrite(destAddr, packedPageData, FLASH_UNLOCK_KEY, FlashProgramOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + if (FLASH_OperationStatusGet() != FLASH_WRITE_ERROR) { + break; + } + } +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_hardware_nonblocking.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_hardware_nonblocking.h new file mode 100644 index 0000000..43f16c4 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_hardware_nonblocking.h @@ -0,0 +1,203 @@ + +/** + * FLASH Generated Driver Header File + * + * @file flash.h + * + * @ingroup Flash Driver + * + * @brief This is the generated driver header file for the FLASH driver + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_NONBLOCKING_HARDWARE_H +#define FLASH_NONBLOCKING_HARDWARE_H + +#include +#include +#include +#include "flash_types.h" +/** + @ingroup flashdriver + @brief Defines FLASH Flash PC unit size +*/ +#define FLASH_PC_UNIT_SIZE 2U +/** + @ingroup flashdriver + @brief Defines FLASH unlock key value +*/ +#define FLASH_UNLOCK_KEY 0x00AA0055 +/** + @ingroup flashdriver + @brief Defines FLASH write row size in instruction counts +*/ +#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U +/** + @ingroup flashdriver + @brief Defines FLASH write row size in PC counts +*/ +#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE) +/** + @ingroup flashdriver + @brief Defines FLASH erase page size in instruction counts +*/ +#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U +/** + @ingroup flashdriver + @brief Defines FLASH erase page size in PC counts +*/ +#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE) +/** + @ingroup flashdriver + @brief Defines if FLASH has ECC +*/ +#define FLASH_HAS_ECC 1 +/** + @ingroup flashdriver + @brief Defines FLASH erase page mask value +*/ +#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U)) +/** + @ingroup flashdriver + @brief Defines FLASH odd address mask value +*/ +#define FLASH_ODD_ADDRESS_MASK 1U +/** + @ingroup flashdriver + @brief Defines FLASH error mask value +*/ +#define FLASH_ERROR_MASK 0x2100 + + +/** + * @ingroup flashdriver + * @brief This routine erases a page indicated by the page aligned address. + * @param[in] address - Flash page aligned address. + * @return bool - Returns True if operation successful else returns false. + */ +bool FLASH_NonBlockingErasePage(flash_adr_t address, flash_key_t unlockKey); + + +/** + * @ingroup flashdriver + * @brief This routine erases a page indicated by the page aligned address. + * @param[in] panel - Panel to erase. + * @return bool - Returns True if operation successful else returns false. + */ +bool FLASH_NonBlockingEraseBulk(uint32_t panel, flash_key_t unlockKey); + +/* The address in the Read and Write word functions below must be even */ + +/** + * @ingroup flashdriver + * @brief This routine writes two 24 bit instructions to the indicated address in flash. + * @param[in] address - Flash address. + * @param[in] data1 - First 24 bit data to be written(First word). + * @param[in] data2 - Second 24 bit data to be written(Second word). + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteDoubleWord24(flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey); + + +/** + * @ingroup flashdriver + * @brief This routine writes two ,16 bit instructions to the indicated address in flash. + * @param[in] address - Flash address. + * @param[in] data1 - First 16 bit data to be written(First word). + * @param[in] data2 - Second 16 bit data to be written(Second word). + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteDoubleWord16(flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey); + + +/* Program the flash one row at a time. */ + + +/** + * @ingroup flashdriver + * @brief + * This routine writes a single row of data from the location given in *data to the flash location in address. + * Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in + * *data must be row aligned. + * @param[in] address - Flash address. + * @param[in] *data - Address of the data to be written. + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteRow24(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey); + + +/** + * @ingroup flashdriver + * @brief + * This routine writes a single row of data from the location given in *data to the flash location in address. + * Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the + * flash is not programmed.The address in *data must be row aligned. + * @param[in] address - Flash address. + * @param[in] *data - Address of the data to be written. + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteRow16(flash_adr_t address, uint16_t *data, flash_key_t unlockKey); + +/* The address in the Read and Write word functions below must be even */ + +/** + * @ingroup flashdriver + * @brief This routine reads a 24 bit instruction from the indicated address in flash. + * @param[in] address - Flash address. + * @return uint32_t - 24 bit data. + */ +uint32_t FLASH_NonBlockingReadWord24(flash_adr_t address); + + +/** + * @ingroup flashdriver + * @brief This routine reads a 16 bit instruction from the indicated address in flash. + * @param[in] address - Flash address. + * @return uint16_t - 16 bit data. + */ +uint16_t FLASH_NonBlockingReadWord16(flash_adr_t address); + +/** + * @ingroup flashdriver + * @brief This routiner returns the page offset the given flash address. + * @param[in] address - Flash address. + * @return uint32_t - returns offset. + */ +uint16_t FLASH_ErasePageOffsetGet(flash_adr_t address); + + +/** + * @ingroup flashdriver + * @brief This routine returns the page aligned address for a given flash address.. + * @param[in] address - Flash address. + * @return uint32_t - Returns page aligned flash address. + */ +uint32_t FLASH_ErasePageAddressGet(flash_adr_t address); + +#endif /* FLASH_NONBLOCKING_HARDWARE_H */ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_interface.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_interface.h new file mode 100644 index 0000000..a380b44 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_interface.h @@ -0,0 +1,110 @@ + +/** + * flash Generated Driver Interface Header File + * + * @file flash_interface.h + * + * @defgroup Flash Driver + * + * @brief FLASH Driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_INTERFACE_H +#define FLASH_INTERFACE_H + +// Section: Included Files +#include +#include +#include +#include "flash_types.h" + +// Section: Data Type Definitions + + +/** + @ingroup flashdriver + @struct FLASH_INTERFACE + @brief Structure containing the function pointers of FLASH driver. +*/ +struct FLASH_INTERFACE +{ + enum FLASH_RETURN_STATUS (*PageErase)(flash_adr_t address, flash_key_t unlockKey); + ///< Pointer to FLASH_PageErase e.g. \ref FLASH_PageErase + + enum FLASH_RETURN_STATUS (*Write)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_WordWrite e.g. \ref FLASH_WordWrite + + enum FLASH_RETURN_STATUS (*RowWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_RowWrite e.g. \ref FLASH_RowWrite + + enum FLASH_RETURN_STATUS (*Read)(flash_adr_t address, size_t count, uint32_t *data); + ///< Pointer to FLASH_Read e.g. \ref FLASH_Read + + uint32_t (*PageAddressGet)(flash_adr_t address); + ///< Pointer to FLASH_ErasePageAddressGet e.g. \ref FLASH_ErasePageAddressGet + + uint16_t (*PageOffsetGet)(flash_adr_t address); + ///< Pointer to FLASH_ErasePageOffsetGet e.g. \ref FLASH_ErasePageOffsetGet + + enum FLASH_RETURN_STATUS (*OperationStatusGet)(void); + ///< Pointer to FLASH_OperationStatusGet e.g. \ref FLASH_OperationStatusGet + + enum FLASH_RETURN_STATUS (*NonBlockingPageErase)(flash_adr_t address, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingPageErase e.g. \ref FLASH_NonBlockingPageErase + + enum FLASH_RETURN_STATUS (*NonBlockingBulkErase)(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingBulkErase e.g. \ref FLASH_NonBlockingBulkErase + + enum FLASH_RETURN_STATUS (*NonBlockingWordWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingWordWrite e.g. \ref FLASH_NonBlockingWordWrite + + enum FLASH_RETURN_STATUS (*NonBlockingRowWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingRowWrite e.g. \ref FLASH_NonBlockingRowWrite + + enum FLASH_RETURN_STATUS (*NonBlockingRead)(flash_adr_t address, size_t count, uint32_t *data); + ///< Pointer to FLASH_NonBlockingRead e.g. \ref FLASH_NonBlockingRead + + enum FLASH_RETURN_STATUS (*NonBlockingPolledPageErase)(flash_adr_t address, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledPageErase e.g. \ref FLASH_NonBlockingPolledPageErase + + enum FLASH_RETURN_STATUS (*NonBlockingPolledBulkErase)(enum FLASH_PANEL panel, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledBulkErase e.g. \ref FLASH_NonBlockingPolledBulkErase + + enum FLASH_RETURN_STATUS (*NonBlockingPolledWordWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledWordWrite e.g. \ref FLASH_NonBlockingPolledWordWrite + + enum FLASH_RETURN_STATUS (*NonBlockingPolledRowWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledRowWrite e.g. \ref FLASH_NonBlockingPolledRowWrite + + enum FLASH_RETURN_STATUS (*NonBlockingPolledRead)(flash_adr_t address, size_t count, uint32_t *data); + ///< Pointer to FLASH_NonBlockingPolledRead e.g. \ref FLASH_NonBlockingPolledRead +}; + +#endif //FLASH_INTERFACE_H diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_nonblocking.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_nonblocking.h new file mode 100644 index 0000000..eefb0ff --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_nonblocking.h @@ -0,0 +1,144 @@ + +/** + * FLASH Generated Driver Header File + * + * @file flash.h + * + * @ingroup Flash Driver + * + * @brief FLASH driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_NONBLOCKING_H +#define FLASH_NONBLOCKING_H + +#include +#include +#include +#include "xc.h" +#include "flash_interface.h" +#include "flash_hardware_nonblocking.h" + +#include "flash_interface.h" + +// Section: Data Type Definitions + +/** + @ingroup flashdriver + @brief Structure object of type FLASH_INTERFACE assigned with name + displayed in the Melody Driver User interface. A structure pointer can be used to achieve portability + across the FLASH having same interface structure. +*/ + +extern const struct FLASH_INTERFACE flash; + +// Section: Data Type Definitions + +/** + * @ingroup flashdriver + * @brief This function initializes the nvm controller. + * @return void + */ +void FLASH_Initialize(); + +/** + * @ingroup flashdriver + * @brief This function gets the status of nvm controller. + * @return returns the status of the previous operation. + */ +enum FLASH_RETURN_STATUS FLASH_OperationStatusGet(); + +/** + * @ingroup flashdriver + * @brief This function erases a page. + * @param[in] flashAddress : Flash address + * @param[in] unlockKey : Flash unlock key + * @param[in] callbackHandler : Pointer to call back handler + * @param[in] context : Optional pointer to context to handle user contexts + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase(flash_adr_t flashAddress, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + +/** + * @ingroup flashdriver + * @brief This function erases a panel. + * @param[in] panel : Flash panel to erase + * @param[in] unlockKey : Flash unlock key + * @return * @return returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + + +/** + * @ingroup flashdriver + * @brief This function writes the specified data to the specified address. + * @param[in] flashAddress : Flash address + * @param[in] data : Pointer of the data to be written. + * @param[in] unlockKey : Flash unlock Key. + * @param[in] callbackHandler : pointer to call back handler + * @param[in] context : Optional pointer to context to handle user contexts + * This will write the TWO WORDS pointed to by the pointer. + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingWordWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + +/** + * @ingroup flashdriver + * @brief This function writes the specified data to the specified address. + * @param[in] flashAddress : Flash address + * @param[in] data : Pointer of the data to be written + * @param[in] unlockKey : Flash unlock Key. + * @param[in] callbackHandler : Pointer to call back handler + * @param[in] context : Optional pointer to context to handle user contexts + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingRowWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callback, void* context); + +/** + * @ingroup flashdriver + * @brief This function reads the data from the specified address. + * @param[in] flashAddress : Flash address of + * @param[out] data : Pointer to read the data + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingRead(flash_adr_t flashAddress, size_t count, flash_data_t *data); + + +#endif /* FLASH_NONBLOCKING_H */ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_types.h new file mode 100644 index 0000000..1224f6c --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/flash_types.h @@ -0,0 +1,77 @@ + +/** + * flash Generated Driver Types Header File + * + * @file flash_types.h + * + * @ingroup Flash Driver + * + * @brief FLASH Driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_TYPES_H +#define FLASH_TYPES_H + +typedef void (*FLASH_CALLBACK)(void *); + +typedef uint32_t flash_adr_t; +typedef uint32_t flash_data_t; +typedef uint32_t flash_key_t; + +/** + @ingroup flashdriver + @enum FLASH_PANEL + @brief This enum is be used for the flash panel numbers and maximum flash panels. +*/ +enum FLASH_PANEL +{ + FLASH_PANEL_1 = 0, + FLASH_PANEL_2 = 1, + FLASH_PANEL_MAX_PANELS +}; + +/** + @ingroup flashdriver + @enum FLASH_RETURN_STATUS + @brief This enum is be used to return the status of write, read and erase operation. +*/ +enum FLASH_RETURN_STATUS { + FLASH_NO_ERROR, /**< No error occurred */ + FLASH_INVALID_ADDRESS, /**< Invalid address */ + FLASH_INVALID_DATA, /**< Invalid data */ + FLASH_WRITE_ERROR, /**< Write error has occurred */ + FLASH_READ_ERROR, /**< Read error has occurred */ + FLASH_ERASE_ERROR, /**< Flash erase error occurred */ + FLASH_INVALID_CALLBACK_HANDLER, /**< Invalid parameter to operation */ + FLASH_OP_BUSY, /**< Flash is physically busy */ + FLASH_OP_IN_PROGRESS /**< Flash operation is in progress */ +}; + +#endif //FLASH_TYPES_H diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/src/flash_asm_nonblocking.s b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/src/flash_asm_nonblocking.s new file mode 100644 index 0000000..056760a --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/src/flash_asm_nonblocking.s @@ -0,0 +1,721 @@ +;/******************************************************************************* +; flash.s for PIC24 and dsPIC33 Cores +; +; Summary: +; Assembly language optimized helper routines required flash functions +; +; Description: +; Assembly language optimized for flash access +; +;*******************************************************************************/ +; +;// DOM-IGNORE-BEGIN +;/******************************************************************************* +; Copyright (C) 2016 Microchip Technology Inc. +; +; MICROCHIP SOFTWARE NOTICE AND DISCLAIMER: You may use this software, and any +; derivatives created by any person or entity by or on your behalf, exclusively +; with Microchip's products. Microchip and its licensors retain all ownership +; and intellectual property rights in the accompanying software and in all +; derivatives here to. +; +; This software and any accompanying information is for suggestion only. It +; does not modify Microchip's standard warranty for its products. You agree +; that you are solely responsible for testing the software and determining its +; suitability. Microchip has no obligation to modify, test, certify, or +; support the software. +; +; THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER +; EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED +; WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR +; PURPOSE APPLY TO THIS SOFTWARE, ITS INTERACTION WITH MICROCHIP'S PRODUCTS, +; COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. +; +; IN NO EVENT, WILL MICROCHIP BE LIABLE, WHETHER IN CONTRACT, WARRANTY, TORT +; (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY), STRICT LIABILITY, +; INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, SPECIAL, PUNITIVE, +; EXEMPLARY, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, FOR COST OR EXPENSE OF +; ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWSOEVER CAUSED, EVEN IF +; MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. +; TO THE FULLEST EXTENT ALLOWABLE BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL +; CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF +; FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. +; +; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE +; TERMS. +;*******************************************************************************/ + .equ WRITE_DWORD_CODE, 0x4001 + .equ ERASE_PAGE_CODE, 0x4003 + .equ ACTIVE_BULK_ERASE_CODE, 0x400E + .equ INACTIVE_BULK_ERASE_CODE, 0x4004 + .equ FLASH_WRITE_ROW_CODE, 0x4002 + .equ ERASE_WRITE_OP_MASK, 0x520F + .equ FLASH_ERASE_WRITE_OP_MASK, 0x520F + .equ FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS, 128 + .equ FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS, 1024 + .equ FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS, 1024 * 2 + .equ FLASH_ERASE_PAGE_MASK, (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1)) + .data + _FlashKey: .long 0xFFFFFFFF + .text + .pushsection .NVM_NonBlockingFlash, code + + +/** + * ;void FLASH_NonBlockingUnlock(uint32_t key); + * Used to program the flash key in memory variable located in RAM + * the valid key is 0x00AA0055 + * + * + * @param key 32-bit (unsigned long) for the key + * + * Registers used: w0 w1 + * + * Inputs: + * w0,w1 = long data - Flash Key to save (32 bits) + * + */ + + .global _FLASH_NonBlockingUnlock + .type _FLASH_NonBlockingUnlock, @function + reset + _FLASH_NonBlockingUnlock: + mov #_FlashKey, W2 + mov W0, [W2++] + mov W1, [W2] + return; + +/** + * ;void FLASH_NonBlockingLock(); + * Locks the flash from programming by resetting the NVMKEY in memory + * + * + * @param key 32-bit (unsigned long) for the key + * + * Registers used: w0 w1 + * + * Inputs: + * w0,w1 = long data - Flash Key to save (32 bits) + * + */ + + .global _FLASH_NonBlockingLock + .type _FLASH_NonBlockingLock, @function + .extern NVMKEY + + reset + _FLASH_NonBlockingLock: + clr W0 + clr W1 + rcall _FLASH_NonBlockingUnlock + clr NVMKEY + return; + + /** + * ;void FLASH_NonBlockingSendNvmKey(uint32_t key); + * Procedure to take the NVM key from memory and program the flash controller + * with it. A valid key is 0x00AA0055 + * + * + * @param key 32-bit (unsigned long) key + * + * Registers used: w0 w1 (Preserved) + * + * Inputs: + * w0,w1 = long data - Flash Key to use (32 bits) + */ + reset + .global _FLASH_NonBlockingSendNvmKey + .type _FLASH_NonBlockingSendNvmKey, @function + .extern NVMKEY + .extern TBLPAG + + reset +_FLASH_NonBlockingSendNvmKey: + push W0 + push W1 + + mov #_FlashKey, w1 + + ; Disable interrupts + push INTCON2 ; Save Global Interrupt Enable bit. + bclr INTCON2, #15 ; Disable interrupts + + ; Write the KEY sequence + mov [W1++], W0 + mov W0, NVMKEY + mov [W1], W0 + mov W0, NVMKEY + bset NVMCON, #15 + + ; Insert two NOPs after programming + nop + nop + ; Restore interrupts to original value. + pop INTCON2 + + pop W1 + pop W0 + return + + +/** + * ;uint32_t FLASH_NonBlockingReadWord24(uint32_t flashAddress); + * Reads the 24 bit instruction located at the address passed to this function. + * + * + * @param flashAddress 24-bit (unsigned long) specifying a target address + * that needs to be read. Needs to be aligned to an even + * address. + * + * Registers used: w0 w1 w2 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to read (24 bits) + * + * outputs: + * w0,w1 = 32 bit data contains the flash data read. + **/ + + reset + .global _FLASH_NonBlockingReadWord24 + .type _FLASH_NonBlockingReadWord24, @function + .extern TBLPAG + + + _FLASH_NonBlockingReadWord24: + mov TBLPAG, W2 + mov W1, TBLPAG ; Little endian, w1 has MSW, w0 has LSX + tblrdh [W0], W1 ; read MSW of data to high latch + tblrdl [W0], W0 ; read LSW of data + mov W2, TBLPAG ; Restore register, + return + +/** + * ;uint16_t FLASH_NonBlockingReadWord16(uint32_t flashAddress); + * Reads the 16 bit instruction located at the address passed to this function. + * Address must be aligned to an even address. + * + * + * @param flashAddress 24-bit (unsigned long) specifying a target address + * that needs to be read. Needs to be aligned to an even + * address. + * + * Registers used: w0 w1 w2 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to read (24 bits) + * + * outputs: + * w0 = 16 bit data contains the flash data read. + * + **/ + + reset + .global _FLASH_NonBlockingReadWord16 + .type _FLASH_NonBlockingReadWord16, @function + .extern TBLPAG + + + _FLASH_NonBlockingReadWord16: + mov TBLPAG, W2 + mov W1, TBLPAG ; Little endian, w1 has MSW, w0 has LSX + tblrdl [W0], W0 ; read LSW of data + mov W2, TBLPAG ; restore register + return + + +/** + * void FLASH_NonBlockingErasePage(unsigned long flashAddress); + * Erases the page containing the specified address. Be very careful if calling + * this function as the function will erase any legal page, + * + * NOTE: This function can take upwards of 45ms on some device families and + * target pages to complete. At frequencies appreciably slower than the maximum + * device frequency, even longer may be required. Therefore, you may need to + * issue a ClrWdt() call before calling this function, assuming the Watchdog + * timer is enabled. This also means that you should not configure a watchdog + * timeout of less than ~64ms, even when you pre-clear the timeout. This + * function does NOT internally clear the watchdog for you as it is packaged as + * a library routine where not everyone would desire such behavior. + * + * @param flashAddress 24-bit (unsigned long) specifying the first address on the page + * to be erased. Must be page aligned. + * + * Registers used: w0 w1 w2 w3 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to erase (24 bits) + * w2,w3 = long data - NVM Unlock Key + * + * outputs: + * 0 - Fail + * 1 - Pass + * + **/ + + .global _FLASH_NonBlockingErasePage + .type _FLASH_NonBlockingErasePage, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + reset + + + +_FLASH_NonBlockingErasePage: + push w0 + push w1 + push w2 + mov w2 , w0 + mov w3 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + mov #FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS-1, w2 ; get mask and validate all lower bits = 0 + and w2, w0, w2 + bra NZ,3f + + mov #ERASE_PAGE_CODE, w2 + mov w2, NVMCON + mov w0, NVMADR + mov w1, NVMADRU ; MSB + + call _FLASH_NonBlockingSendNvmKey + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + +/** + * void FLASH_NonBlockingEraseBulk(unsigned char inactive); + * Erases the partition. Be very careful if calling + * this function as the function will erase the partition! + * + * NOTE: This function can take upwards of 45ms on some device families and + * target pages to complete. At frequencies appreciably slower than the maximum + * device frequency, even longer may be required. Therefore, you may need to + * issue a ClrWdt() call before calling this function, assuming the Watchdog + * timer is enabled. This also means that you should not configure a watchdog + * timeout of less than ~64ms, even when you pre-clear the timeout. This + * function does NOT internally clear the watchdog for you as it is packaged as + * a library routine where not everyone would desire such behavior. + * + * @param partition (unsigned char) if 0, indicates the single partition (for single + * partition devices) or active partition (for dual partition devices). + * if 1, indicates the inactive partition (for dual partition devices only). + * + * Registers used: w0 w1 w2 w3 + * TBLPAG Preserved + * + * Inputs: + * w0 = char data - indicates active/inactive partition + * w1,w2 = long data - NVM Unlock Key + * + * outputs: + * 0 - Fail + * 1 - Pass + * + **/ + .global _FLASH_NonBlockingEraseBulk + .type _FLASH_NonBlockingEraseBulk, @function + .extern TBLPAG + .extern NVMCON + reset + +_FLASH_NonBlockingEraseBulk: + push w0 + push w1 + push w2 + push w3 + mov w2 , w0 + mov w3 , w1 + call _FLASH_NonBlockingUnlock + pop w3 + pop w2 + pop w1 + pop w0 + + mov #ACTIVE_BULK_ERASE_CODE, w2 ; default to active/single partition + mov #0, w3 + cpseq w3, w0 ; if w0 == 0, skip the next instruction + mov #INACTIVE_BULK_ERASE_CODE, w2 ; load the inactive partition bulk-erase code + + mov w2, NVMCON + mov w0, NVMADR + mov w1, NVMADRU ; MSB + + call _FLASH_NonBlockingSendNvmKey + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + /** + * ;void FLASH_NonBlockingWriteDoubleWord24(uint32_t flashAddress, uint32_t instructionData0, uint32_t instructionData1); + * Writes two 24-bit instruction to the flash at the flashAdddress + * Only the lower 24 bits of each instruction will be written since the flash + * is only 24 bits wide and all data in the upper 8 bits will be lost. + * + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param uint32_t instructionData0 24 bit instruction to be written first. + * @param uint32_t instructionData1 24 bit instruction to be written second. + * + * + * Registers used: w0 w1 w2 w3 w4 w5 w6 w7 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2,w3 = long data - 24 bits of data to write to flash (24 bits) + * w4,w5 = long data - 24 bits of data to write to flash (24 bits) + * w6,w7 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteDoubleWord24 + .type _FLASH_NonBlockingWriteDoubleWord24, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + reset + +_FLASH_NonBlockingWriteDoubleWord24: + push w0 + push w1 + push w2 + mov w6 , w0 + mov w7 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + + btsc w0, #0 ; Check for a valid address Bit 0 and Bit 1 clear + bra 3f + btsc w0, #1 + bra 3f + +good24: + mov W1,NVMADRU + mov W0,NVMADR + + mov #WRITE_DWORD_CODE, W0 + mov W0, NVMCON + + mov TBLPAG, W0 ; save it + mov #0xFA,W1 + mov W1,TBLPAG + mov #0,W1 + + ; Perform the TBLWT instructions to write the latches + tblwtl W2,[W1] + tblwth W3,[W1++] + tblwtl W4,[W1] + tblwth w5,[W1++] + + call _FLASH_NonBlockingSendNvmKey + + + mov W0, TBLPAG + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + + /** + * ;void FLASH_NonBlockingWriteDoubleWord16(uint32_t flashAddress, uint16_t Data0, uint16_t Data1, uint32_t unlockKey); + * Writes two 16-bit words to the flash at the flashAdddress + * The upper 8 bits of the 24 bit flash entry will have its data programmed as + * 0xFF. + * + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param uint16_t Data0 16 bit word to be written first. + * @param uint16_t Data1 16 bit word to be written second. + * + * Registers used: w0 w1 w2 w3 w4 w5 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2 = 16 bit data - 16 bits of data to write to flash + * w3 = 16 bit data - 16 bits of data to write to flash + * w4,w5 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteDoubleWord16 + .type _FLASH_NonBlockingWriteDoubleWord16, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + reset + + _FLASH_NonBlockingWriteDoubleWord16: + push w0 + push w1 + push w2 + mov w4 , w0 + mov w5 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + + btsc w0, #0 ; Check for a valid address Bit 0 and Bit 1 clear + bra 3f + btsc w0, #1 + bra 3f + +good16: + mov W1,NVMADRU + mov W0,NVMADR + + mov TBLPAG, W1 ; save it + + mov #WRITE_DWORD_CODE, W0 + mov W0, NVMCON + + mov #0xFA,W0 + mov W0,TBLPAG + mov #0,W0 + + tblwtl W2,[W0] ; Perform the TBLWT instructions to write the latches + mov #0xFF,W2 + tblwth W2,[W0++] + tblwtl W3,[W0] + tblwth W2,[W0++] + + call _FLASH_NonBlockingSendNvmKey + + + mov w1, TBLPAG + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + + +/** + * ;void FLASH_NonBlockingWriteRow24(uint32_t flashAddress, uint32_t *data, uint32_t unlockKey); + * Writes a single Row to the address flashAddress from the address of data + * Since this is passed as a 32 bit value + * and flash is only 24 bit wide, all data in the upper 8 bits will be lost. + * + * This method uses the built in row load and program from a RAM buffer. + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param *data 16 bit value of the SRAM address to read the data from. + * + * Registers used: w0 w1 w2 w3 w4 w5 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2,w3 = long data - 24 bits of data address to write to flash (24 bits) + * w4,w5 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteRow24 + .type _FLASH_NonBlockingWriteRow24, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + .extern NVMSRCADRL + reset + + _FLASH_NonBlockingWriteRow24: + push w0 + push w1 + push w2 + push w3 + mov w4 , w0 + mov w5 , w1 + call _FLASH_NonBlockingUnlock + pop w3 + pop w2 + pop w1 + pop w0 + + mov #((FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS*2)-1), w3 ; get mask and validate all lower bits = 0 + and w3, w0, w3 + bra NZ,3f + + + mov W0,NVMADR + mov W1,NVMADRU + + mov #FLASH_WRITE_ROW_CODE, W0 ; RPDF = 0 so not compressed + mov W0, NVMCON + + mov W2, NVMSRCADRL + + call _FLASH_NonBlockingSendNvmKey + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + + + +/** + * ;void FLASH_NonBlockingWriteRow16(uint32_t flashAddress, uint16_t sourceRamAddress, uint32_t unlockKey); + * Writes a single Row to the address flashAddress from the sourceAddress + * Since this is passed as a 32 bit value + * and flash is only 24 bit wide, all data in the upper 8 bits will be lost. + * + * This method uses the built in row load and program from a RAM buffer. + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param sourceAddress 16 bit value of the address to read the data from. + * + * Registers used: w0 w1 w2 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2 = 16 bit - 16 bits of data address to write to flash (16 bits) + * w4,w5 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteRow16 + .type _FLASH_NonBlockingWriteRow16, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + .extern NVMSRCADRL + reset + + _FLASH_NonBlockingWriteRow16: + push w0 + push w1 + push w2 + mov w4 , w0 + mov w5 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + + mov #((FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS*2)-1), w3 ; get mask and validate all lower bits = 0 + and w3, w0, w3 + bra NZ,3f + + + mov W0,NVMADR + mov W1,NVMADRU + + mov #WRITE_DWORD_CODE, W0 + mov W0, NVMCON + + mov #0xFA,W0 + mov W0,TBLPAG + mov #0,W0 + + mov #FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS, W1 + mov #0xFF, W4 +1: + tblwtl [w2++], [W0] ; Perform the TBLWT instructions to write the latches + tblwth W4, [W0++] + tblwtl [w2++], [W0] ; Perform the TBLWT instructions to write the latches + tblwth W4, [W0--] + + call _FLASH_NonBlockingSendNvmKey + +prog_wait: + btsc NVMCON, #15 + bra prog_wait + + + inc2 NVMADR + inc2 NVMADR + sub #2, W1 + bra NZ, 1b + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + +;uint16_t FLASH_ErasePageOffsetGet(uint32_t flashAddress) + .global _FLASH_ErasePageOffsetGet + .type _FLASH_ErasePageOffsetGet, @function + +_FLASH_ErasePageOffsetGet: + mov #((~FLASH_ERASE_PAGE_MASK) & 0xFFFF), W2 + and w2, w0, w0 + return + +;uint32_t FLASH_ErasePageAddressGet(uint32_t flashAddress); + + .global _FLASH_ErasePageAddressGet + .type _FLASH_ErasePageAddressGet, @function + +_FLASH_ErasePageAddressGet: + + mov #(FLASH_ERASE_PAGE_MASK & 0xFFFF) , W2 ;LSW + and w2, w0, w0 + mov #((FLASH_ERASE_PAGE_MASK >> 16) & 0xFFFF), W2 ; MSW + and w2, w1, w1 + + return + + + .popsection diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/src/flash_nonblocking.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/src/flash_nonblocking.c new file mode 100644 index 0000000..c34dc96 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/flash/src/flash_nonblocking.c @@ -0,0 +1,277 @@ +/** + * FLASH Generated Driver Source File + * + * @file flash.c + * + * @ingroup Flash Driver + * + * @brief This is the generated driver source file for FLASH driver + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include "../flash_nonblocking.h" + +// User callback and context handles. +static void (*userCallbackHandler)(void *) = NULL; +static void *userContext = NULL; +bool lock = false; + + +// Section: Driver Interface +const struct FLASH_INTERFACE flash = { + .PageAddressGet = FLASH_ErasePageAddressGet, + .PageOffsetGet = FLASH_ErasePageOffsetGet, + .NonBlockingPageErase = FLASH_NonBlockingPageErase, + .NonBlockingBulkErase = FLASH_NonBlockingBulkErase, + .NonBlockingRead = FLASH_NonBlockingRead, + .NonBlockingWordWrite = FLASH_NonBlockingWordWrite, + .NonBlockingRowWrite = FLASH_NonBlockingRowWrite, + .NonBlockingPolledPageErase = NULL, + .NonBlockingPolledBulkErase = NULL, + .NonBlockingPolledRead = NULL, + .NonBlockingPolledWordWrite = NULL, + .NonBlockingPolledRowWrite = NULL, + .OperationStatusGet = FLASH_OperationStatusGet + +}; + +void FLASH_Initialize(void) +{ + // Flash Interrupt + IFS0bits.NVMIF = 0U; + IEC0bits.NVMIE = 1U; +} + +void __attribute__ ( ( interrupt, no_auto_psv ) ) _NVMInterrupt(void) +{ + IFS0bits.NVMIF = 0U; + + //Interrupt means operation completion, release the lock + lock = false; + + if (NULL != userCallbackHandler) { + (*userCallbackHandler)(userContext); + } +} + + +enum FLASH_RETURN_STATUS FLASH_OperationStatusGet() +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_NO_ERROR; + if(NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + if(NVMCON & FLASH_ERROR_MASK) + { + flashReturnStatus = FLASH_WRITE_ERROR; + } + lock = false; + } + return flashReturnStatus; +} + + +enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase(uint32_t flashAddress, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if (0U != ((uint16_t)flashAddress & ~FLASH_ERASE_PAGE_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingErasePage(flashAddress, unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + + +enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if ((panel < 0) || (panel >= FLASH_PANEL_MAX_PANELS)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingEraseBulk(panel, unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + +enum FLASH_RETURN_STATUS FLASH_NonBlockingWordWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if (NULL == data) + { + flashReturnStatus = FLASH_INVALID_DATA; + } + else if (0U != ((uint16_t)flashAddress & FLASH_ODD_ADDRESS_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + // Save the handler and context to call for completion of this operation. + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingWriteDoubleWord24(flashAddress, *data, *(data+1), unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + +enum FLASH_RETURN_STATUS FLASH_NonBlockingRowWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if (NULL == data) + { + flashReturnStatus = FLASH_INVALID_DATA; + } + else if (0U != ((uint16_t)flashAddress & FLASH_ODD_ADDRESS_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + // Save the handler and context to call for completion of this operation. + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingWriteRow24(flashAddress, data, unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + + +enum FLASH_RETURN_STATUS FLASH_NonBlockingRead(flash_adr_t flashAddress, size_t count, flash_data_t *data) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_BUSY; + if(false == lock) + { + if ((NULL == data) || (0 == count)) + { + flashReturnStatus = FLASH_INVALID_DATA; + } + else if (0U != ((uint16_t)flashAddress & FLASH_ODD_ADDRESS_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(0U == NVMCONbits.WR) + { + lock = true; + do + { + *data++ = FLASH_NonBlockingReadWord24(flashAddress); + flashAddress = flashAddress + FLASH_PC_UNIT_SIZE; + } while(--count); + + flashReturnStatus = FLASH_NO_ERROR; + + // Now that the read is done, the lock can be cleared. + lock = false; + } + } + return flashReturnStatus; +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/clock.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/clock.h new file mode 100644 index 0000000..a8c328e --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/clock.h @@ -0,0 +1,90 @@ +/** + * CLOCK Generated Driver Header File + * + * @file clock.h + * + * @defgroup clockdriver Clock Driver + * + * @brief Clock configurator driver for System and Peripheral Clock using dsPIC MCUs. + * + * @version Firmware Driver Version 1.0.2 + * + * @version PLIB Version 1.4.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef CLOCK_H +#define CLOCK_H + +// Section: Included Files + +#include + +/** + @ingroup clockdriver + @brief This macro is used to read the System clock (FOSC) Frequency configured in + the MCC Melody User Interface +*/ +#define CLOCK_SystemFrequencyGet() (8000000UL) + +/** + @ingroup clockdriver + @brief This macro is used to read the Peripheral Clock (FP) Frequency + configured in the MCC Melody User Interface +*/ +#define CLOCK_PeripheralFrequencyGet() ((uint32_t)CLOCK_SystemFrequencyGet() / (uint32_t)2) + +/** + @ingroup clockdriver + @brief This macro is used to read the Instruction Clock (FCY) Frequency + configured in the MCC Melody User Interface +*/ +#define CLOCK_InstructionFrequencyGet() ((uint32_t)CLOCK_SystemFrequencyGet() / (uint32_t)2) + +// Section: CLOCK APIs + +/** + * @ingroup clockdriver + * @brief Initializes all the INTERNAL OSCILLATOR sources and clock switch configurations. + * @return none + */ +void CLOCK_Initialize(void); + +/** + * @ingroup clockdriver + * @brief Returns Auxiliary PLL status + * @pre \ref CLOCK_Initialize() should be called for the associated + * function to work. + * @return true - Auxiliary PLL locked + * @return false - Auxiliary PLL not locked + */ +bool CLOCK_AuxPllLockStatusGet(void); + +#endif /* CLOCK_H */ +/** + End of File +*/ + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/dmt.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/dmt.h new file mode 100644 index 0000000..93ff4e9 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/dmt.h @@ -0,0 +1,169 @@ +/** + * DMT Generated Driver Header File + * + * @file dmt.h + * + * @defgroup dmtdriver DMT Driver + * + * @brief Deadman Timer (DMT) driver using dsPIC MCUs. The functionality + * is to interrupt the processor in the event of a software + * malfunction. + * + * @skipline @version Firmware Driver Version 1.2.1 + * + * @skipline @version PLIB Version 1.1.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef DMT_H +#define DMT_H + +// Section: Included Files +#include +#include + +// Section: DMT APIs + +/** + * @ingroup dmtdriver + * @brief Initializes the DMT module + * @param none + * @return none + */ +void DMT_Initialize ( void ); + +/** + * @ingroup dmtdriver + * @brief Writes the PreClear Pattern for DMTPRECLR register. + * @pre This function should be called before calling \ref DMT_Clear + * @param none + * @return none + */ +void DMT_PreClear(void); + +/** + * @ingroup dmtdriver + * @brief Enables the DMT module + * @param none + * @return none + */ +void DMT_Enable(void); + +/** + * @ingroup dmtdriver + * @brief Checks the PreClear Status and clears the DMT Fetch Counter + * @pre \ref DMT_PreClear() should be called for the associated function to work + * @param none + * @return none + */ +void DMT_Clear(void); + +/** + * @ingroup dmtdriver + * @brief Returns the Window Open status + * @param none + * @return true - Window Open status bit is set + * @return false - Window Open status bit is not set + */ +bool DMT_IsWindowOpen(void); + +/** + * @ingroup dmtdriver + * @brief Checks for the PreClear sequence was initiated and + * done before the Clear sequence is done. + * @param none + * @return true - PreClear sequence performed successfully + * @return false - PreClear sequence failed + */ +bool DMT_IsPreCleared(void); + +/** + * @ingroup dmtdriver + * @brief Reads the DMT counter register + * @param none + * @return 32 bit timeout counter value + */ +uint32_t DMT_TimeoutCounterGet(void); + +/** + * @ingroup dmtdriver + * @brief Reads the DMT Window Interval Counter + * @param none + * @return 32-bit window interval counter value + */ +uint32_t DMT_WindowTimeoutCounterGet(void); + +/** + * @ingroup dmtdriver + * @brief Gets the DMT status + * @param none + * @return status value of DMT + */ +uint16_t DMT_StatusGet(void); + +/** + * @ingroup dmtdriver + * @brief Returns the current counter value + * @pre Value will not be compensated for the instructions involved in + * call-stack-push, reading SFR and call-stack-pop operations. + * @param none + * @return Returns the 32 bit counter value + */ +uint32_t DMT_CounterGet(void); + +/** + * @ingroup dmtdriver + * @brief Returns the current counter value + * @pre Value will be compensated for the instructions involved in + * call-stack-push, reading SFR and call-stack-pop operations. + * @param none + * @return Returns the 32 bit counter value + */ +uint32_t DMT_CalibratedCounterGet(void); + +/** + * @ingroup dmtdriver + * @brief This function can be used to override default callback and to define + * custom callback for DMT Event event. + * @param[in] handler - Address of the callback function. + * @return none + */ +void DMT_EventCallbackRegister(void (*handler)(void)); + +/** + * @ingroup dmtdriver + * @brief This is the default callback with weak attribute. The user can + * override and implement the default callback without weak attribute + * or can register a custom callback function using \ref DMT_EventCallbackRegister. + * @param none + * @return none + */ +void DMT_EventCallback(void); + +#endif // DMT.h + + + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/interrupt.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/interrupt.h new file mode 100644 index 0000000..de8a6d1 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/interrupt.h @@ -0,0 +1,93 @@ +/** + * INTERRUPT Generated Driver Header File + * + * @file interrupt.h + * + * @defgroup interruptdriver Interrupt Driver + * + * @brief Interrupt Priority configuration driver using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.1.2 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef INTERRUPT_H +#define INTERRUPT_H + +// Section: Driver Interface Function + +/** + * @ingroup interruptdriver + * @brief Initializes the interrupt priorities of the modules that have been configured + * @param none + * @return none + */ +void INTERRUPT_Initialize(void); + +/** + * @ingroup interruptdriver + * @brief Deinitializes the INTERRUPT to POR values + * @param none + * @return none + */ +void INTERRUPT_Deinitialize(void); + +/** + * @ingroup interruptdriver + * @brief Enables the global interrupt bit + * @param none + * @return none + */ +inline static void INTERRUPT_GlobalEnable(void) +{ + __builtin_enable_interrupts(); +} + +/** + * @ingroup interruptdriver + * @brief Disables the global interrupt bit + * @param none + * @return none + */ +inline static void INTERRUPT_GlobalDisable(void) +{ + __builtin_disable_interrupts(); +} + +/** + * @ingroup interruptdriver + * @brief Returns the pending Interrupt Vector number + * @param none + * @return Returns the pending Interrupt Vector number + */ +inline static uint16_t INTERRUPT_VectorNumberGet(void) +{ + return _VECNUM; +} + +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/interrupt_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/interrupt_types.h new file mode 100644 index 0000000..5423e70 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/interrupt_types.h @@ -0,0 +1,60 @@ +/** + * INTERRUPT Generated Driver Header File + * + * @file interrupt_types.h + * + * @defgroup interruptdriver + * + * @brief This is the generated driver types header file for the INTERRUPT driver + * + * @skipline @version Firmware Driver Version 1.1.2 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef INTERRUPT_TYPES_H +#define INTERRUPT_TYPES_H + +/** + * @ingroup interruptdriver + * @enum interrupt_types.h + * @brief Defines the interrupt priority values. +*/ + +enum INTERRUPT_PRIORITY +{ + INTERRUPT_PRIORITY_1 = 1, + INTERRUPT_PRIORITY_2 = 2, + INTERRUPT_PRIORITY_3 = 3, + INTERRUPT_PRIORITY_4 = 4, + INTERRUPT_PRIORITY_5 = 5, + INTERRUPT_PRIORITY_6 = 6, + INTERRUPT_PRIORITY_7 = 7, + INTERRUPT_MAX_PRIORITY = 7 +}; + +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/pins.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/pins.h new file mode 100644 index 0000000..4ec030e --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/pins.h @@ -0,0 +1,158 @@ +/** + * PINS Generated Driver Header File + * + * @file pins.h + * + * @defgroup pinsdriver Pins Driver + * + * @brief The Pin Driver directs the operation and function of + * the selected device pins using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.2 + * + * @skipline @version PLIB Version 1.3.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef PINS_H +#define PINS_H +// Section: Includes +#include + +// Section: Device Pin Macros + +/** + * @ingroup pinsdriver + * @brief Sets the RE5 GPIO Pin which has a custom name of LED1 to High + * @pre The RE5 must be set as Output Pin + * @param none + * @return none + */ +#define LED1_SetHigh() (_LATE5 = 1) + +/** + * @ingroup pinsdriver + * @brief Sets the RE5 GPIO Pin which has a custom name of LED1 to Low + * @pre The RE5 must be set as Output Pin + * @param none + * @return none + */ +#define LED1_SetLow() (_LATE5 = 0) + +/** + * @ingroup pinsdriver + * @brief Toggles the RE5 GPIO Pin which has a custom name of LED1 + * @pre The RE5 must be set as Output Pin + * @param none + * @return none + */ +#define LED1_Toggle() (_LATE5 ^= 1) + +/** + * @ingroup pinsdriver + * @brief Reads the value of the RE5 GPIO Pin which has a custom name of LED1 + * @param none + * @return none + */ +#define LED1_GetValue() _RE5 + +/** + * @ingroup pinsdriver + * @brief Configures the RE5 GPIO Pin which has a custom name of LED1 as Input + * @param none + * @return none + */ +#define LED1_SetDigitalInput() (_TRISE5 = 1) + +/** + * @ingroup pinsdriver + * @brief Configures the RE5 GPIO Pin which has a custom name of LED1 as Output + * @param none + * @return none + */ +#define LED1_SetDigitalOutput() (_TRISE5 = 0) + +/** + * @ingroup pinsdriver + * @brief Sets the RE6 GPIO Pin which has a custom name of LED2 to High + * @pre The RE6 must be set as Output Pin + * @param none + * @return none + */ +#define LED2_SetHigh() (_LATE6 = 1) + +/** + * @ingroup pinsdriver + * @brief Sets the RE6 GPIO Pin which has a custom name of LED2 to Low + * @pre The RE6 must be set as Output Pin + * @param none + * @return none + */ +#define LED2_SetLow() (_LATE6 = 0) + +/** + * @ingroup pinsdriver + * @brief Toggles the RE6 GPIO Pin which has a custom name of LED2 + * @pre The RE6 must be set as Output Pin + * @param none + * @return none + */ +#define LED2_Toggle() (_LATE6 ^= 1) + +/** + * @ingroup pinsdriver + * @brief Reads the value of the RE6 GPIO Pin which has a custom name of LED2 + * @param none + * @return none + */ +#define LED2_GetValue() _RE6 + +/** + * @ingroup pinsdriver + * @brief Configures the RE6 GPIO Pin which has a custom name of LED2 as Input + * @param none + * @return none + */ +#define LED2_SetDigitalInput() (_TRISE6 = 1) + +/** + * @ingroup pinsdriver + * @brief Configures the RE6 GPIO Pin which has a custom name of LED2 as Output + * @param none + * @return none + */ +#define LED2_SetDigitalOutput() (_TRISE6 = 0) + +/** + * @ingroup pinsdriver + * @brief Initializes the PINS module + * @param none + * @return none + */ +void PINS_Initialize(void); + + + +#endif diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/reset.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/reset.h new file mode 100644 index 0000000..9730d08 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/reset.h @@ -0,0 +1,76 @@ +/** + * RESET Generated Driver Header File + * + * @file reset.h + * + * @defgroup resetdriver Reset Driver + * + * @brief Reset driver using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.1.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef RESET_H +#define RESET_H + +#include +#include "reset_types.h" + +/** + * @ingroup resetdriver + * @brief Returns the cause of previous reset + * @pre This function should be called before any use of CLRWDT + * since it has a side-effect of clearing the appropriate bits in the + * register showing reset cause. + * @param none + * @return Returns a value corresponding to a possible cause for reset. + */ +uint16_t RESET_CauseGet(void); + +/** + * @ingroup resetdriver + * @brief It handles the reset cause by clearing the cause register values. + * This is a weak attribute function. The user can + * override and implement the same function without weak attribute. + * @param none + * @return none + */ +void RESET_CauseHandler(void); + +/** + * @ingroup resetdriver + * @brief Clears the Reset Cause register + * @param none + * @return none + */ +void RESET_CauseClearAll(void); + +#endif /* RESET_H */ +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/reset_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/reset_types.h new file mode 100644 index 0000000..6833a27 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/reset_types.h @@ -0,0 +1,74 @@ +/** + * RESET Generated Driver Types Header File + * + * @file reset_types.h + * + * @ingroup resetdriver + * + * @brief This is the generated driver types header file for the RESET driver + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.1.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef RESET_TYPES_H +#define RESET_TYPES_H + +/** + @ingroup resetdriver + @enum RESET_TYPES + @brief Defines the RCON error types +*/ +enum RESET_TYPES +{ + RESET_ERROR_RCON_TRAPR = 1, /**< A Trap Conflict Reset has occurred */ + RESET_ERROR_RCON_IOPUWR = 2, /**< An illegal opcode detection, an illegal address mode or Uninitialized W register used as an Address Pointer caused a Reset */ + RESET_ERROR_RCON_CM = 3, /**< A Configuration Mismatch Reset has occurred */ + RESET_ERROR_RCON_WDTO_ISR = 4 /**< WDT time-out has occurred */ +}; + +/** + @ingroup resetdriver + @enum RESET_MASKS + @brief Defines the RESET cause mask location +*/ +enum RESET_MASKS +{ + RESET_MASK_POR = 0x0001, /**< Defines the power ON Reset flag mask location */ + RESET_MASK_WDTO = 0x0010, /**< Defines the watchdog timeout reset flag mask location */ + RESET_MASK_SWR = 0x0040, /**< Defines the software reset mask location */ + RESET_MASK_EXTR = 0x0080, /**< Defines the external reset mask location */ + RESET_MASK_CM = 0x0200, /**< Defines the configuration mismatch reset mask location */ + RESET_MASK_IOPUWR = 0x4000, /**< Defines the illegal opcode or uninitialized W access reset mask location */ + RESET_MASK_TRAPR = 0x8000, /**< Defines the trap reset mask location */ +}; + +#endif /* RESET_TYPES_H */ + +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/clock.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/clock.c new file mode 100644 index 0000000..b84fa25 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/clock.c @@ -0,0 +1,103 @@ +/** + * CLOCK Generated Driver Source File + * + * @file clock.c + * + * @ingroup clockdriver + * + * @brief This is the generated source file for CLOCK driver + * + * @version Firmware Driver Version 1.0.2 + * + * @version PLIB Version 1.4.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Includes +#include +#include +#include "../clock.h" + +void CLOCK_Initialize(void) +{ + /* + Input frequency : 8.00 MHz + Clock source : FRC Oscillator + System frequency (Fosc) : 8.00 MHz + Clock switching enabled : false + Auxiliary clock source : FRC Oscillator + Auxiliary clock input frequency : 8.00 MHz + Auxiliary clock PLL output frequency (AFpllo) : 8.00 MHz + */ + // RCDIV FRC/1; PLLPRE 1:1; DOZE 1:8; DOZEN disabled; ROI disabled; + CLKDIV = 0x3001; + // PLLDIV 150; + PLLFBD = 0x96; + // TUN Center frequency; + OSCTUN = 0x0; + // PLLPOST 1:4; VCODIV FVCO/4; POST2DIV 1:1; + PLLDIV = 0x41; + // ENAPLL disabled; FRCSEL FRC Oscillator; APLLPRE 1:1; + ACLKCON1 = 0x101; + // APLLFBDIV 150; + APLLFBD1 = 0x96; + // APSTSCLR 1:4; APOST2DIV 1:1; AVCODIV FVCO/4; + APLLDIV1 = 0x41; + // CANCLKEN disabled; CANCLKSEL FVCO/4; CANCLKDIV Divide by 1; + CANCLKCON = 0x500; + // ROEN disabled; DIVSWEN disabled; ROSLP disabled; ROSEL ; OE disabled; ROSIDL disabled; + REFOCONL = 0x0; + // RODIV 0; + REFOCONH = 0x0; + // ROTRIM 0; + REFOTRIMH = 0x0; + // IOLOCK disabled; + RPCON = 0x0; + // PMDLOCK disabled; + PMDCON = 0x0; + // ADC1MD enabled; T1MD enabled; U2MD enabled; U1MD enabled; SPI2MD enabled; SPI1MD enabled; QEIMD enabled; PWMMD enabled; I2C1MD enabled; C1MD enabled; + PMD1 = 0x0; + // CCP2MD enabled; CCP1MD enabled; CCP4MD enabled; CCP3MD enabled; CCP7MD enabled; CCP8MD enabled; CCP5MD enabled; CCP6MD enabled; CCP9MD enabled; + PMD2 = 0x0; + // U3MD enabled; CRCMD enabled; I2C2MD enabled; I2C3MD enabled; QEI2MD enabled; PMPMD enabled; + PMD3 = 0x0; + // REFOMD enabled; + PMD4 = 0x0; + // DMA1MD enabled; DMA2MD enabled; DMA3MD enabled; DMA0MD enabled; SPI3MD enabled; + PMD6 = 0x0; + // PTGMD enabled; CMP1MD enabled; CMP3MD enabled; CMP2MD enabled; + PMD7 = 0x0; + // DMTMD enabled; CLC3MD enabled; OPAMPMD enabled; BIASMD enabled; CLC4MD enabled; SENT1MD enabled; CLC1MD enabled; CLC2MD enabled; SENT2MD enabled; + PMD8 = 0x0; + // CF no clock failure; NOSC FRC; CLKLOCK unlocked; OSWEN Switch is Complete; + __builtin_write_OSCCONH((uint8_t) (0x00)); + __builtin_write_OSCCONL((uint8_t) (0x00)); +} + +bool CLOCK_AuxPllLockStatusGet(void) +{ + return ACLKCON1bits.APLLCK; +} + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/config_bits.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/config_bits.c new file mode 100644 index 0000000..c7ef102 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/config_bits.c @@ -0,0 +1,118 @@ +/** + * CONFIGURATION_BITS Generated Driver Source File + * + * @file configuration_bits.c + * + * @defgroup config_bitsdriver CONFIGBITS Driver + * + * @brief Device Configuration Bits using dsPIC MCUs + * + * @version Firmware Driver Version 1.0.1 + * + * @version PLIB Version 1.2.2 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Configuration bits: selected in the GUI + +// FSEC +#pragma config BWRP = OFF //Boot Segment Write-Protect bit->Boot Segment may be written +#pragma config BSS = DISABLED //Boot Segment Code-Protect Level bits->No Protection (other than BWRP) +#pragma config BSEN = OFF //Boot Segment Control bit->No Boot Segment +#pragma config GWRP = OFF //General Segment Write-Protect bit->General Segment may be written +#pragma config GSS = DISABLED //General Segment Code-Protect Level bits->No Protection (other than GWRP) +#pragma config CWRP = OFF //Configuration Segment Write-Protect bit->Configuration Segment may be written +#pragma config CSS = DISABLED //Configuration Segment Code-Protect Level bits->No Protection (other than CWRP) +#pragma config AIVTDIS = OFF //Alternate Interrupt Vector Table bit->Disabled AIVT + +// FBSLIM +#pragma config BSLIM = 0x1fff //Boot Segment Flash Page Address Limit bits + +// FOSCSEL +#pragma config FNOSC = FRC //Oscillator Source Selection->Internal Fast RC (FRC) +#pragma config IESO = OFF //Two-speed Oscillator Start-up Enable bit->Start up with user-selected oscillator source + +// FOSC +#pragma config POSCMD = NONE //Primary Oscillator Mode Select bits->Primary Oscillator disabled +#pragma config OSCIOFNC = ON //OSC2 Pin Function bit->OSC2 is general purpose digital I/O pin +#pragma config FCKSM = CSDCMD //Clock Switching Mode bits->Both Clock switching and Fail-safe Clock Monitor are disabled +#pragma config PLLKEN = ON //PLL Lock Status Control->PLL lock signal will be used to disable PLL clock output if lock is lost +#pragma config XTCFG = G3 //XT Config->24-32 MHz crystals +#pragma config XTBST = ENABLE //XT Boost->Boost the kick-start + +// FWDT +#pragma config RWDTPS = PS1048576 //Run Mode Watchdog Timer Post Scaler select bits->1:1048576 +#pragma config RCLKSEL = LPRC //Watchdog Timer Clock Select bits->Always use LPRC +#pragma config WINDIS = ON //Watchdog Timer Window Enable bit->Watchdog Timer in Non-Window mode +#pragma config WDTWIN = WIN25 //Watchdog Timer Window Select bits->WDT Window is 25% of WDT period +#pragma config SWDTPS = PS1048576 //Sleep Mode Watchdog Timer Post Scaler select bits->1:1048576 +#pragma config FWDTEN = ON_SW //Watchdog Timer Enable bit->WDT controlled via SW, use WDTCON.ON bit + +// FPOR +#pragma config BISTDIS = DISABLED //Memory BIST Feature Disable->mBIST on reset feature disabled + +// FICD +#pragma config ICS = PGD1 //ICD Communication Channel Select bits->Communicate on PGC1 and PGD1 +#pragma config JTAGEN = OFF //JTAG Enable bit->JTAG is disabled +#pragma config NOBTSWP = DISABLED //BOOTSWP instruction disable bit->BOOTSWP instruction is disabled + +// FDMTIVTL +#pragma config DMTIVTL = 0x0 //Dead Man Timer Interval low word + +// FDMTIVTH +#pragma config DMTIVTH = 0x0 //Dead Man Timer Interval high word + +// FDMTCNTL +#pragma config DMTCNTL = 0x0 //Lower 16 bits of 32 bit DMT instruction count time-out value (0-0xFFFF) + +// FDMTCNTH +#pragma config DMTCNTH = 0x0 //Upper 16 bits of 32 bit DMT instruction count time-out value (0-0xFFFF) + +// FDMT +#pragma config DMTDIS = OFF //Dead Man Timer Disable bit->Dead Man Timer is Disabled and can be enabled by software + +// FDEVOPT +#pragma config ALTI2C1 = OFF //Alternate I2C1 Pin bit->I2C1 mapped to SDA1/SCL1 pins +#pragma config ALTI2C2 = OFF //Alternate I2C2 Pin bit->I2C2 mapped to SDA2/SCL2 pins +#pragma config ALTI2C3 = OFF //Alternate I2C3 Pin bit->I2C3 mapped to SDA3/SCL3 pins +#pragma config SMBEN = SMBUS //SM Bus Enable->SMBus input threshold is enabled +#pragma config SPI2PIN = PPS //SPI2 Pin Select bit->SPI2 uses I/O remap (PPS) pins + +// FALTREG +#pragma config CTXT1 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 1 bits->Not Assigned +#pragma config CTXT2 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 2 bits->Not Assigned +#pragma config CTXT3 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 3 bits->Not Assigned +#pragma config CTXT4 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 4 bits->Not Assigned + +// FBTSEQ +#pragma config BSEQ = 0x002 //Relative value defining which partition will be active after device Reset; the partition containing a lower boot number will be active +#pragma config IBSEQ = 0xFFD //The one's complement of BSEQ; must be calculated by the user and written during device programming. + +// FBOOT +#pragma config BTMODE = DUAL //Device Boot Mode Configuration->Device is in Dual Partition mode + +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/dmt.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/dmt.c new file mode 100644 index 0000000..ffc639f --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/dmt.c @@ -0,0 +1,159 @@ +/** + * DMT Generated Driver Source File + * + * @file dmt.c + * + * @ingroup dmtdriver + * + * @brief This is the generated driver source file for DMT driver + * + * @skipline @version Firmware Driver Version 1.2.1 + * + * @skipline @version PLIB Version 1.1.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Included Files +#include +#include +#include "../dmt.h" +#include "../interrupt.h" + +// Section: Private Variable Definitions +static bool bPreCleared = false; +uint32_t calibOffset = 0; +static void (*DMT_EventHandler)(void) = NULL; + +// Section: File specific functions + +void DMT_Calibrate(void); + +// Section: DMT Module APIs +void DMT_Initialize(void) +{ + INTERRUPT_GlobalDisable(); + DMT_Calibrate(); + INTERRUPT_GlobalEnable(); + + DMT_EventCallbackRegister(&DMT_EventCallback); + + IEC2bits.DMTIE = 1U; +} + +void DMT_Enable(void) +{ + // Set the Bit ON = 1 + DMTCON = 0x8000; +} + +void DMT_PreClear(void) +{ + DMTPRECLR = 0x4000; + + // To keep track of Preclear operation is performed + bPreCleared = true; +} + +void DMT_Clear(void) +{ + bPreCleared = false; + while((DMTSTAT & 0x0001) != 0x0001) + { + } + + DMTCLR = 0x0008; +} + +bool DMT_IsWindowOpen(void) +{ + bool status = false; + + if((DMTSTAT & 0x0001) == 0x0001) + { + status = true; + } + + return status; +} + +bool DMT_IsPreCleared(void) +{ + return bPreCleared; +} + +uint32_t DMT_TimeoutCounterGet(void) +{ + uint32_t counter = 0; + counter = (uint32_t)(DMTPSCNTH & 0x0000FFFF) << 16; + return (counter | DMTPSCNTL); +} + +uint32_t DMT_WindowTimeoutCounterGet(void) +{ + uint32_t winTimeoutCounter = 0; + winTimeoutCounter = (uint32_t)(DMTPSINTVH & 0x0000FFFF) << 16; + return (winTimeoutCounter | DMTPSINTVL); +} + +uint16_t DMT_StatusGet(void) +{ + uint16_t status = 0; + status = (uint16_t)(DMTSTAT & 0xE1); + return status; +} + +uint32_t DMT_CounterGet(void) +{ + uint32_t counter = 0; + counter = (uint32_t)(DMTCNTH & 0x0000FFFF) << 16; + return (counter | DMTCNTL); +} + +void DMT_EventCallbackRegister(void (*handler)(void)) +{ + if(NULL != handler) + { + DMT_EventHandler = handler; + } +} + +void __attribute__ ((weak)) DMT_EventCallback( void ) +{ + +} + + +void __attribute__ ((interrupt, no_auto_psv)) _DMTInterrupt(void) +{ + if(NULL != DMT_EventHandler) + { + (*DMT_EventHandler)(); + } + IFS2bits.DMTIF = 0U; +} + +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/dmt_asm.s b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/dmt_asm.s new file mode 100644 index 0000000..a72679f --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/dmt_asm.s @@ -0,0 +1,113 @@ +;/******************************************************************************* +; +;DMT Generated Driver Header File +; +; @file dmt_asm.s +; +; @defgroup dmtdriver DMT Driver +; +; @brief Assembly language optimized helper routines required for calibration +; +; @skipline @version Firmware Driver Version 1.2.1 +; +; @skipline @version PLIB Version 1.1.1 +; +; @skipline Device : dsPIC33CK256MP508 +; +;*******************************************************************************/ +; +;// DOM-IGNORE-BEGIN +;/******************************************************************************* +; Copyright (C) 2016 Microchip Technology Inc. +; +; MICROCHIP SOFTWARE NOTICE AND DISCLAIMER: You may use this software, and any +; derivatives created by any person or entity by or on your behalf, exclusively +; with Microchip's products. Microchip and its licensors retain all ownership +; and intellectual property rights in the accompanying software and in all +; derivatives here to. +; +; This software and any accompanying information is for suggestion only. It +; does not modify Microchip's standard warranty for its products. You agree +; that you are solely responsible for testing the software and determining its +; suitability. Microchip has no obligation to modify, test, certify, or +; support the software. +; +; THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER +; EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED +; WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR +; PURPOSE APPLY TO THIS SOFTWARE, ITS INTERACTION WITH MICROCHIP'S PRODUCTS, +; COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. +; +; IN NO EVENT, WILL MICROCHIP BE LIABLE, WHETHER IN CONTRACT, WARRANTY, TORT +; (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY), STRICT LIABILITY, +; INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, SPECIAL, PUNITIVE, +; EXEMPLARY, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, FOR COST OR EXPENSE OF +; ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWSOEVER CAUSED, EVEN IF +; MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. +; TO THE FULLEST EXTENT ALLOWABLE BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL +; CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF +; FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. +; +; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE +; TERMS. +;*******************************************************************************/ + + +/** + * ;uint32_t DMT_CalibratedCounterGet(void); + * Gets the count of DMT counter just before calling CalibratedCounterGet function + * + * @param none + * @return 32-bit (unsigned long) caliberated count + * + * Registers used: w0 w1 w2 + * + */ + + .global _DMT_CounterGet + .global _DMT_CalibratedCounterGet + .global _calibOffset + .type _DMT_CalibratedCounterGet, @function + reset + + _DMT_CalibratedCounterGet: + call _DMT_CounterGet + push w2 + mov _calibOffset, w2 + SUBR w2, w0, w0 + mov #0x0, w2 + SUBBR w2, w1, w1 + pop w2 + return + +/** + * ;void DMT_Calibrate(void); + * Calculates and stores offset value during DMT_CounterGet function call + * + * Registers used: w0 w1 w2 + * + */ + + .global _DMT_CounterGet + .global _DMT_Calibrate + .global _calibOffset + .type _DMT_Calibrate, @function + .extern DMTCNTL + reset + + _DMT_Calibrate: + push w0 + push w1 + push w2 + mov DMTCNTL, w0 + push w0 + call _DMT_CounterGet + pop w2 + sub w0, w2, w2 + dec w2, w2 + mov w2, _calibOffset + pop w2 + pop w1 + pop w0 + return + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/interrupt.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/interrupt.c new file mode 100644 index 0000000..b57eafa --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/interrupt.c @@ -0,0 +1,61 @@ +/** + * INTERRUPT Generated Driver Source File + * + * @file interrupt.c + * + * @ingroup interruptdriver + * + * @brief This is the generated driver source file for INTERRUPT driver + * + * @skipline @version Firmware Driver Version 1.1.2 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Includes +#include +#include "../interrupt.h" + +// Section: Driver Interface Function Definitions + +void INTERRUPT_Initialize(void) +{ + // DMT: Dead Man Timer + // Priority: 1 + IPC11bits.DMTIP = 1; + + // NVM: NVM Write complete + // Priority: 1 + IPC3bits.NVMIP = 1; + +} + +void INTERRUPT_Deinitialize(void) +{ + //POR default value of priority + IPC11bits.DMTIP = 4; + IPC3bits.NVMIP = 4; +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/pins.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/pins.c new file mode 100644 index 0000000..8873589 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/pins.c @@ -0,0 +1,113 @@ +/** + * PINS Generated Driver Source File + * + * @file pins.c + * + * @ingroup pinsdriver + * + * @brief This is the generated driver source file for PINS driver. + * + * @skipline @version Firmware Driver Version 1.0.2 + * + * @skipline @version PLIB Version 1.3.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Includes +#include +#include +#include "../pins.h" + +// Section: File specific functions + +// Section: Driver Interface Function Definitions +void PINS_Initialize(void) +{ + /**************************************************************************** + * Setting the Output Latch SFR(s) + ***************************************************************************/ + LATA = 0x0000; + LATB = 0x0000; + LATC = 0x0000; + LATD = 0x0010; + LATE = 0x0000; + + /**************************************************************************** + * Setting the GPIO Direction SFR(s) + ***************************************************************************/ + TRISA = 0x001F; + TRISB = 0xFFFF; + TRISC = 0xFFFF; + TRISD = 0xFFEF; + TRISE = 0xFF9F; + + + /**************************************************************************** + * Setting the Weak Pull Up and Weak Pull Down SFR(s) + ***************************************************************************/ + CNPUA = 0x0000; + CNPUB = 0x0000; + CNPUC = 0x0000; + CNPUD = 0x0000; + CNPUE = 0x0000; + CNPDA = 0x0000; + CNPDB = 0x0000; + CNPDC = 0x0000; + CNPDD = 0x0000; + CNPDE = 0x0000; + + + /**************************************************************************** + * Setting the Open Drain SFR(s) + ***************************************************************************/ + ODCA = 0x0000; + ODCB = 0x0000; + ODCC = 0x0000; + ODCD = 0x0000; + ODCE = 0x0000; + + + /**************************************************************************** + * Setting the Analog/Digital Configuration SFR(s) + ***************************************************************************/ + ANSELA = 0x001F; + ANSELB = 0x009F; + ANSELC = 0x00CF; + ANSELD = 0x2C00; + ANSELE = 0x000F; + + /**************************************************************************** + * Set the PPS + ***************************************************************************/ + __builtin_write_RPCON(0x0000); // unlock PPS + + RPINR18bits.U1RXR = 0x0043; //RD3->UART1:U1RX; + RPOR18bits.RP68R = 0x0001; //RD4->UART1:U1TX; + + __builtin_write_RPCON(0x0800); // lock PPS + + +} + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/reset.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/reset.c new file mode 100644 index 0000000..3d0d850 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/reset.c @@ -0,0 +1,204 @@ +/** + * RESET Generated Driver Source File + * + * @file reset.c + * + * @ingroup resetdriver + * + * @brief This is the generated driver source file for RESET driver + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.1.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include +#include +#include "../reset.h" + +// Section: File specific functions + + +/** + @ingroup resetdriver + @static RESET cause from trap + @brief RESET cause from trap +*/ +static bool RESET_CauseFromTrap(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_TRAPR) == (uint16_t) RESET_MASK_TRAPR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Illegal Opcode + @brief RESET cause from Illegal Opcode +*/ +static bool RESET_CauseFromIllegalOpcode(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_IOPUWR) == (uint16_t) RESET_MASK_IOPUWR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Configuration Mismatch + @brief RESET cause from Configuration Mismatch +*/ +static bool RESET_CauseFromConfigurationMismatch(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_CM) == (uint16_t) RESET_MASK_CM) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from External + @brief RESET cause from External +*/ +static bool RESET_CauseFromExternal(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_EXTR) == (uint16_t) RESET_MASK_EXTR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Software + @brief RESET cause from Software +*/ +static bool RESET_CauseFromSoftware(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_SWR) == (uint16_t) RESET_MASK_SWR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Watchdog Time + @brief RESET cause from Watchdog Time +*/ +static bool RESET_CauseFromWatchdogTimer(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_WDTO) == (uint16_t) RESET_MASK_WDTO) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Clear + @brief RESET cause from Clear +*/ +static void RESET_CauseClear(enum RESET_MASKS resetFlagMask) +{ + RCON = RCON & (~resetFlagMask); +} + +uint16_t RESET_CauseGet(void) +{ + return RCON; +} + +void __attribute__ ((weak)) RESET_CauseHandler(void) +{ + uint16_t resetCause = RESET_CauseGet(); + + if(RESET_CauseFromTrap(resetCause)) + { + RESET_CauseClear(RESET_MASK_TRAPR); + } + + if(RESET_CauseFromIllegalOpcode(resetCause)) + { + RESET_CauseClear(RESET_MASK_IOPUWR); + } + + if(RESET_CauseFromConfigurationMismatch(resetCause)) + { + RESET_CauseClear(RESET_MASK_CM); + } + + if(RESET_CauseFromExternal(resetCause)) + { + RESET_CauseClear(RESET_MASK_EXTR); + } + + if(RESET_CauseFromSoftware(resetCause)) + { + RESET_CauseClear(RESET_MASK_SWR); + } + + if(RESET_CauseFromWatchdogTimer(resetCause)) + { + RESET_CauseClear(RESET_MASK_WDTO); + } +} + +void RESET_CauseClearAll(void) +{ + RCON = 0x00; +} +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/system.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/system.c new file mode 100644 index 0000000..736ece1 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/system.c @@ -0,0 +1,58 @@ +/** + * MAIN Generated Driver Header File + * + * @file system.c + * + * @ingroup systemdriver + * + * @brief This is the generated driver header file for the System driver + * + * @version Driver Version 1.0.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include "../system.h" +#include "../system_types.h" +#include "../clock.h" +#include "../pins.h" +#include "../dmt.h" +#include "../../flash/flash_nonblocking.h" +#include "../../uart/uart1.h" +#include "../interrupt.h" + + +void SYSTEM_Initialize(void) +{ + CLOCK_Initialize(); + PINS_Initialize(); + DMT_Initialize(); + FLASH_Initialize(); + UART1_Initialize(); + INTERRUPT_GlobalEnable(); + INTERRUPT_Initialize(); +} + +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/traps.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/traps.c new file mode 100644 index 0000000..be2fe71 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/src/traps.c @@ -0,0 +1,168 @@ +/** + * TRAPS Generated Driver Source File + * + * @file traps.c + * + * @ingroup trapsdriver + * + * @brief This is the generated driver source file for TRAPS driver + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Included Files +#include +#include "../traps.h" + +#define ERROR_HANDLER __attribute__((interrupt,no_auto_psv)) +#define FAILSAFE_STACK_GUARDSIZE 8 + +// A private place to store the error code if we run into a severe error + +static uint16_t TRAPS_error_code = -1; + +// Section: Driver Interface Function Definitions + +//@brief Halts +void __attribute__((weak)) TRAPS_halt_on_error(uint16_t code) +{ + TRAPS_error_code = code; +#ifdef __DEBUG + /* If we are in debug mode, cause a software breakpoint in the debugger */ + __builtin_software_breakpoint(); + while(1) + { + + } +#else + // Trigger software reset + __asm__ volatile ("reset"); +#endif +} + +// @brief Sets the stack pointer to a backup area of memory, in case we run into +// a stack error (in which case we can't really trust the stack pointer) + +inline static void use_failsafe_stack(void) +{ + static uint8_t failsafe_stack[32]; + asm volatile ( + " mov %[pstack], W15\n" + : + : [pstack]"r"(failsafe_stack) + ); + + /* Controls where the stack pointer limit is, relative to the end of the + * failsafe stack + */ + SPLIM = (uint16_t)(((uint8_t *)failsafe_stack) + sizeof(failsafe_stack) - (uint16_t) FAILSAFE_STACK_GUARDSIZE); +} + +/** Address error Trap vector**/ +void ERROR_HANDLER _AddressError(void) +{ + INTCON1bits.ADDRERR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_ADDRESS_ERR); +} + +/** Generic Hard Trap vector**/ +void ERROR_HANDLER _HardTrapError(void) +{ + INTCON4bits.SGHT = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_HARD_ERR); +} + +/** Generic Soft Trap vector**/ +void ERROR_HANDLER _SoftTrapError(void) +{ + if(INTCON3bits.DOOVR == 1) + { + INTCON3bits.DOOVR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_DOOVR_ERR); + } + +#ifdef _DAE + if(INTCON3bits.DAE == 1) + { + INTCON3bits.DAE = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_DAE_ERR); + } + +#endif + if(INTCON3bits.NAE == 1) + { + INTCON3bits.NAE = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_NVM_ERR); + } + +#ifdef _CAN + if(INTCON3bits.CAN == 1) + { + INTCON3bits.CAN = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_CAN_ERR); + } + +#endif + if(INTCON3bits.APLL == 1) + { + INTCON3bits.APLL = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_APLL_ERR); + } + + while(1) + { + } +} + +/** Oscillator Fail Trap vector**/ +void ERROR_HANDLER _OscillatorFail(void) +{ + INTCON1bits.OSCFAIL = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_OSC_FAIL); +} + +/** Math Error Trap vector**/ +void ERROR_HANDLER _MathError(void) +{ + INTCON1bits.MATHERR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_MATH_ERR); +} + +/** Stack Error Trap Vector**/ +void ERROR_HANDLER _StackError(void) +{ + /* We use a failsafe stack: the presence of a stack-pointer error + * means that we cannot trust the stack to operate correctly unless + * we set the stack pointer to a safe place. + */ + use_failsafe_stack(); + + INTCON1bits.STKERR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_STACK_ERR); +} + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/system.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/system.h new file mode 100644 index 0000000..d1ac3ff --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/system.h @@ -0,0 +1,106 @@ +/** + * MAIN Generated Driver Header File + * + * @file system.h + * + * @defgroup systemdriver System Driver + * + * @brief System driver using dsPIC MCUs. + * + * @version Driver Version 1.0.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include "xc.h" +#include "stdint.h" +#include "system_types.h" + +#ifndef SYSTEM_H +#define SYSTEM_H + +/** + * @ingroup systemdriver + * @brief Initializes the System module + * @return none + */ +void SYSTEM_Initialize(void); + +/** + * @ingroup systemdriver + * @brief Initializes the CPU core control register + * @return none + */ +inline static void SYSTEM_CORCONInitialize() +{ + CORCON = (CORCON & 0x00F2) | CORCON_MODE_PORVALUES; +} + +/** + * @ingroup systemdriver + * @brief This inline function sets the CPU core control register operating mode + * to a value that is decided by the SYSTEM_CORCON_MODES argument. + * @param[in] modeValue - SYSTEM_CORCON_MODES initialization mode specifier + * @return none + */ +inline static void SYSTEM_CORCONModeOperatingSet(SYSTEM_CORCON_MODES modeValue) +{ + CORCON = (CORCON & 0x00F2) | modeValue; +} + +/** + * @ingroup systemdriver + * @brief This inline function sets the value of CPU core control register + * @param[in] value - value that needs to be written to the CPU core control register + * @return none + */ +inline static void SYSTEM_CORCONRegisterValueSet(uint16_t value) +{ + CORCON = value; +} + +/** + * @ingroup systemdriver + * @brief This inline function gets the value of CPU core control register + * @return value of the CPU core control register + */ +inline static uint16_t SYSTEM_CORCONRegisterValueGet(void) +{ + return CORCON; +} + +/** + * @ingroup systemdriver + * @brief This inline function gets the base address of the DEVID register + * for the currently selected device + * @return base address of the DEVID register + */ +inline static uint32_t SYSTEM_DeviceIdRegisterAddressGet(void) +{ + return __DEVID_BASE; +} + +#endif /* SYSTEM_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/system_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/system_types.h new file mode 100644 index 0000000..9202d0a --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/system_types.h @@ -0,0 +1,96 @@ +/** + * MAIN Generated Driver Types Header File + * + * @file system_types.h + * + * @ingroup systemdriver + * + * @brief This is the generated driver types header file for the System driver + * + * @version Driver Version 1.0.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef SYSTEM_TYPES_H +#define SYSTEM_TYPES_H + +/** + Section: Type defines + */ + +/** + @ingroup systemdriver + @enum CORCON_MODE_TYPE + @brief CORCON initialization type enumerator +*/ +typedef enum CORCON_MODE_TYPE +{ + CORCON_MODE_PORVALUES = 0x0020, /**< Use POR values of CORCON */ + CORCON_MODE_ENABLEALLSATNORMAL_ROUNDBIASED = 0x00E2, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable normal + ACCA/ACCB saturation mode and set + rounding to Biased (conventional) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_ENABLEALLSATNORMAL_ROUNDUNBIASED = 0x00E0, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable normal + ACCA/ACCB saturation mode and set + rounding to Unbiased (convergent) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_DISABLEALLSAT_ROUNDBIASED = 0x0022, /**< Disable saturation for ACCA, ACCB + and Dataspace write and set + rounding to Biased (conventional) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_DISABLEALLSAT_ROUNDUNBIASED = 0x0020, /**< Disable saturation for ACCA, ACCB + and Dataspace write and set + rounding to Unbiased (convergent) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_ENABLEALLSATSUPER_ROUNDBIASED = 0x00F2, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable super + ACCA/ACCB saturation mode and set + rounding to Biased (conventional) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_ENABLEALLSATSUPER_ROUNDUNBIASED = 0x00F0, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable super + ACCA/ACCB saturation mode and set + rounding to Unbiased (convergent) + mode. Rest of CORCON settings are + set to the default POR values. + */ +} SYSTEM_CORCON_MODES; + +#endif /* SYSTEM_TYPES_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/traps.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/traps.h new file mode 100644 index 0000000..8042675 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/traps.h @@ -0,0 +1,79 @@ +/** + * TRAPS Generated Driver Header File + * + * @file traps.h + * + * @defgroup trapsdriver Traps Driver + * + * @brief Traps driver with handler for all types of traps using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef TRAPS_H +#define TRAPS_H + +// Section: Included Files +#include + +// Section: Data Type Definitions + +/** + @ingroup trapsdriver + @enum TRAPS_ERROR_CODE + @brief Defines the TRAPS error codes +*/ +enum TRAPS_ERROR_CODE +{ +// Traps + TRAPS_OSC_FAIL = 0, /**< Oscillator Fail Trap vector */ + TRAPS_STACK_ERR = 1, /**< Stack Error Trap Vector */ + TRAPS_ADDRESS_ERR = 2, /**< Address error Trap vector */ + TRAPS_MATH_ERR = 3, /**< Math Error Trap vector */ + TRAPS_HARD_ERR = 7, /**< Generic Hard Trap vector */ + TRAPS_DAE_ERR = 9, /**< Generic Soft Trap vector */ + TRAPS_DOOVR_ERR = 10, /**< Generic Soft Trap vector */ + TRAPS_APLL_ERR = 11, /**< Generic Soft Trap vector */ + TRAPS_NVM_ERR = 12, /**< Generic Soft Trap vector */ + TRAPS_CAN_ERR = 13, /**< Generic Soft Trap vector */ +}; + +// Section: Driver Interface Function + +/** + * @ingroup trapsdriver + * @brief Stores the trap error code and waits forever. + * This is a weak attribute function. The user can + * override and implement the same function without weak attribute. + * @param[in] code - trap error code + * @return none + */ +void TRAPS_halt_on_error(uint16_t code); + +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/watchdog.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/watchdog.h new file mode 100644 index 0000000..e05e530 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/system/watchdog.h @@ -0,0 +1,88 @@ +/** + * WATCHDOG Generated Driver Header File + * + * @file watchdog.h + * + * @defgroup watchdogdriver WDT Driver + * + * @brief Watchdog Timer Driver using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.2 + * + * @skipline @version PLIB Version 1.2.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef WATCHDOG_H +#define WATCHDOG_H + +#include + +// Section: Type defines + +/** + * @ingroup watchdogdriver + * @brief This macro holds the key value to clear Watchdog Timer (WDT) +*/ +#define WATCHDOG_CLR_KEY 0x5743 + +/** + * @ingroup watchdogdriver + * @brief This inline function is used to enable the Watchdog Timer (WDT) using the software bit + * @param none + * @return none + */ +inline static void WATCHDOG_TimerSoftwareEnable(void) +{ + WDTCONLbits.ON = 1; +} + +/** + * @ingroup watchdogdriver + * @brief This inline function is used to disable the Watchdog Timer (WDT) using the software bit + * @param none + * @return none + */ +inline static void WATCHDOG_TimerSoftwareDisable(void) +{ + WDTCONLbits.ON = 0; +} + +/** + * @ingroup watchdogdriver + * @brief This inline function is used to clear the Watchdog Timer (WDT) + * @param none + * @return none + */ +inline static void WATCHDOG_TimerClear(void) +{ + WDTCONH = WATCHDOG_CLR_KEY; +} + +#endif /* WATCHDOG_H */ +/** + End of File +*/ + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/src/uart1.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/src/uart1.c new file mode 100644 index 0000000..2e58b47 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/src/uart1.c @@ -0,0 +1,301 @@ +/** + * UART1 Generated Driver Source File + * + * @file uart1.c + * + * @ingroup uartdriver + * + * @brief This is the generated driver source file for the UART1 driver. + * + * @skipline @version Firmware Driver Version 1.7.0 + * + * @skipline @version PLIB Version 1.5.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Included Files +#include +#include +#include +#include +#include "../uart1.h" + +// Section: Macro Definitions +#define UART1_CLOCK 4000000U +#define UART1_BAUD_TO_BRG_WITH_FRACTIONAL(x) (UART1_CLOCK/(x)) +#define UART1_BAUD_TO_BRG_WITH_BRGH_1(x) (UART1_CLOCK/(4U*(x))-1U) +#define UART1_BAUD_TO_BRG_WITH_BRGH_0(x) (UART1_CLOCK/(16U*(x))-1U) +#define UART1_BRG_TO_BAUD_WITH_FRACTIONAL(x) (UART1_CLOCK/(x)) +#define UART1_BRG_TO_BAUD_WITH_BRGH_1(x) (UART1_CLOCK/(4U*((x)+1U))) +#define UART1_BRG_TO_BAUD_WITH_BRGH_0(x) (UART1_CLOCK/(16U*((x)+1U))) + +#define UART1_MIN_ACHIEVABLE_BAUD_WITH_FRACTIONAL 4U +#define UART1_MIN_ACHIEVABLE_BAUD_WITH_BRGH_1 1U + +// Section: Driver Interface + +const struct UART_INTERFACE UART1_Drv = { + .Initialize = &UART1_Initialize, + .Deinitialize = &UART1_Deinitialize, + .Read = &UART1_Read, + .Write = &UART1_Write, + .IsRxReady = &UART1_IsRxReady, + .IsTxReady = &UART1_IsTxReady, + .IsTxDone = &UART1_IsTxDone, + .TransmitEnable = &UART1_TransmitEnable, + .TransmitDisable = &UART1_TransmitDisable, + .TransmitInterruptEnable = NULL, + .TransmitInterruptDisable = NULL, + .AutoBaudSet = &UART1_AutoBaudSet, + .AutoBaudQuery = &UART1_AutoBaudQuery, + .AutoBaudEventEnableGet = &UART1_AutoBaudEventEnableGet, + .BRGCountSet = &UART1_BRGCountSet, + .BRGCountGet = &UART1_BRGCountGet, + .BaudRateSet = &UART1_BaudRateSet, + .BaudRateGet = &UART1_BaudRateGet, + .ErrorGet = &UART1_ErrorGet, + .RxCompleteCallbackRegister = NULL, + .TxCompleteCallbackRegister = NULL, + .TxCollisionCallbackRegister = NULL, + .FramingErrorCallbackRegister = NULL, + .OverrunErrorCallbackRegister = NULL, + .ParityErrorCallbackRegister = NULL, +}; + +// Section: Private Variable Definitions +static union +{ + struct + { + uint16_t frammingError :1; + uint16_t parityError :1; + uint16_t overrunError :1; + uint16_t txCollisionError :1; + uint16_t autoBaudOverflow :1; + uint16_t reserved :11; + }; + size_t status; +} uartError; + +// Section: UART1 APIs + +void UART1_Initialize(void) +{ +/* + Set the UART1 module to the options selected in the user interface. + Make sure to set LAT bit corresponding to TxPin as high before UART initialization +*/ + // URXEN ; RXBIMD ; UARTEN disabled; MOD Asynchronous 8-bit UART; UTXBRK ; BRKOVR ; UTXEN ; USIDL ; WAKE ; ABAUD ; BRGH ; + U1MODE = 0x0; + // STSEL 1 Stop bit sent, 1 checked at RX; BCLKMOD enabled; SLPEN ; FLO ; BCLKSEL FOSC/2; C0EN ; RUNOVF ; UTXINV ; URXINV ; HALFDPLX ; + U1MODEH = 0x800; + // OERIE ; RXBKIF ; RXBKIE ; ABDOVF ; OERR ; TXCIE ; TXCIF ; FERIE ; TXMTIE ; ABDOVE ; CERIE ; CERIF ; PERIE ; + U1STA = 0x80; + // URXISEL ; UTXBE ; UTXISEL ; URXBE ; STPMD ; TXWRE ; + U1STAH = 0x2E; + // BaudRate 9592.33; Frequency 4000000 Hz; BRG 417; + U1BRG = 0x1A1; + // BRG 0; + U1BRGH = 0x0; + + U1MODEbits.UARTEN = 1; // enabling UART ON bit + U1MODEbits.UTXEN = 1; + U1MODEbits.URXEN = 1; +} + +void UART1_Deinitialize(void) +{ + U1MODE = 0x0; + U1MODEH = 0x0; + U1STA = 0x80; + U1STAH = 0x2E; + U1BRG = 0x0; + U1BRGH = 0x0; +} + +uint8_t UART1_Read(void) +{ + while((U1STAHbits.URXBE == 1)) + { + + } + + if ((U1STAbits.OERR == 1)) + { + U1STAbits.OERR = 0; + } + + return U1RXREG; +} + +void UART1_Write(uint8_t txData) +{ + while(U1STAHbits.UTXBF == 1) + { + + } + + U1TXREG = txData; // Write the data byte to the USART. +} + +bool UART1_IsRxReady(void) +{ + return (U1STAHbits.URXBE == 0); +} + +bool UART1_IsTxReady(void) +{ + return ((!U1STAHbits.UTXBF) && U1MODEbits.UTXEN); +} + +bool UART1_IsTxDone(void) +{ + return (bool)(U1STAbits.TRMT && U1STAHbits.UTXBE); +} + +void UART1_TransmitEnable(void) +{ + U1MODEbits.UTXEN = 1; +} + +void UART1_TransmitDisable(void) +{ + U1MODEbits.UTXEN = 0; +} + +void UART1_AutoBaudSet(bool enable) +{ + U1INTbits.ABDIF = 0U; + U1INTbits.ABDIE = enable; + U1MODEbits.ABAUD = enable; +} + +bool UART1_AutoBaudQuery(void) +{ + return U1MODEbits.ABAUD; +} + +bool UART1_AutoBaudEventEnableGet(void) +{ + return U1INTbits.ABDIE; +} + +size_t UART1_ErrorGet(void) +{ + uartError.status = 0; + if(U1STAbits.FERR == 1U) + { + uartError.status = uartError.status|UART_ERROR_FRAMING_MASK; + } + if(U1STAbits.PERR== 1U) + { + uartError.status = uartError.status|UART_ERROR_PARITY_MASK; + } + if(U1STAbits.OERR== 1U) + { + uartError.status = uartError.status|UART_ERROR_RX_OVERRUN_MASK; + U1STAbits.OERR = 0; + } + if(U1STAbits.TXCIF== 1U) + { + uartError.status = uartError.status|UART_ERROR_TX_COLLISION_MASK; + U1STAbits.TXCIF = 0; + } + if(U1STAbits.ABDOVF== 1U) + { + uartError.status = uartError.status|UART_ERROR_AUTOBAUD_OVERFLOW_MASK; + U1STAbits.ABDOVF = 0; + } + + return uartError.status; +} + +void UART1_BRGCountSet(uint32_t brgValue) +{ + U1BRG = brgValue & 0xFFFFU; + U1BRGH = (brgValue >>16U) & 0x000FU; +} + +uint32_t UART1_BRGCountGet(void) +{ + uint32_t brgValue; + + brgValue = U1BRGH; + brgValue = (brgValue << 16U) | U1BRG; + + return brgValue; +} + +void UART1_BaudRateSet(uint32_t baudRate) +{ + uint32_t brgValue; + + if((baudRate >= UART1_MIN_ACHIEVABLE_BAUD_WITH_FRACTIONAL) && (baudRate != 0)) + { + U1MODEHbits.BCLKMOD = 1; + U1MODEbits.BRGH = 0; + brgValue = UART1_BAUD_TO_BRG_WITH_FRACTIONAL(baudRate); + } + else + { + U1MODEHbits.BCLKMOD = 0; + U1MODEbits.BRGH = 1; + brgValue = UART1_BAUD_TO_BRG_WITH_BRGH_1(baudRate); + } + U1BRG = brgValue & 0xFFFFU; + U1BRGH = (brgValue >>16U) & 0x000FU; +} + +uint32_t UART1_BaudRateGet(void) +{ + uint32_t brgValue; + uint32_t baudRate; + + brgValue = UART1_BRGCountGet(); + if((U1MODEHbits.BCLKMOD == 1) && (brgValue != 0)) + { + baudRate = UART1_BRG_TO_BAUD_WITH_FRACTIONAL(brgValue); + } + else if(U1MODEbits.BRGH == 1) + { + baudRate = UART1_BRG_TO_BAUD_WITH_BRGH_1(brgValue); + } + else + { + baudRate = UART1_BRG_TO_BAUD_WITH_BRGH_0(brgValue); + } + return baudRate; +} + +int __attribute__((__section__(".libc.write"))) write(int handle, void *buffer, unsigned int len) { + unsigned int numBytesWritten = 0 ; + while(!UART1_IsTxDone()); + while(numBytesWritten +#include +#include +#include "uart_interface.h" + +// Section: Data Type Definitions + +/** + @ingroup uartdriver + @brief Structure object of type UART_INTERFACE with the + custom name given by the user in the Melody Driver User interface. + The default name e.g. UART1 can be changed by the + user in the UART user interface. + This allows defining a structure with application specific name + using the 'Custom Name' field. Application specific name allows the + API Portability. +*/ +extern const struct UART_INTERFACE UART1_Drv; + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Initialize API + */ +#define UART1_Drv_Initialize UART1_Initialize + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Deinitialize API + */ +#define UART1_Drv_Deinitialize UART1_Deinitialize + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Read API + */ +#define UART1_Drv_Read UART1_Read + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Write API + */ +#define UART1_Drv_Write UART1_Write + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_IsRxReady API + */ +#define UART1_Drv_IsRxReady UART1_IsRxReady + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_IsTxReady API + */ +#define UART1_Drv_IsTxReady UART1_IsTxReady + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_IsTxDone API + */ +#define UART1_Drv_IsTxDone UART1_IsTxDone + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_TransmitEnable API + */ +#define UART1_Drv_TransmitEnable UART1_TransmitEnable + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_TransmitDisable API + */ +#define UART1_Drv_TransmitDisable UART1_TransmitDisable + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_AutoBaudSet API + */ +#define UART1_Drv_AutoBaudSet UART1_AutoBaudSet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_AutoBaudQuery API + */ +#define UART1_Drv_AutoBaudQuery UART1_AutoBaudQuery + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_AutoBaudEventEnableGet API + */ +#define UART1_Drv_AutoBaudEventEnableGet UART1_AutoBaudEventEnableGet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_ErrorGet API + */ +#define UART1_Drv_ErrorGet UART1_ErrorGet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BRGCountSet API + */ +#define UART1_Drv_BRGCountSet UART1_BRGCountSet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BRGCountGet API + */ +#define UART1_Drv_BRGCountGet UART1_BRGCountGet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BaudRateSet API + */ +#define UART1_Drv_BaudRateSet UART1_BaudRateSet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BaudRateGet API + */ +#define UART1_Drv_BaudRateGet UART1_BaudRateGet + +// Section: UART1 Driver Routines + +/** + * @ingroup uartdriver + * @brief Initializes the UART driver + * @param none + * @return none + */ +void UART1_Initialize(void); + +/** + * @ingroup uartdriver + * @brief Deinitializes the UART to POR values + * @param none + * @return none + */ +void UART1_Deinitialize(void); + +/** + * @ingroup uartdriver + * @brief Reads a byte of data from the UART1 + * @pre UART1_Initialize function should have been called + * before calling this function. The transfer status should be checked + * to see if the receiver is not empty before calling this function. + * @param none + * @return A data byte received by the driver + */ +uint8_t UART1_Read(void); + +/** + * @ingroup uartdriver + * @brief Writes a byte of data to the UART1 + * @pre UART1_Initialize function should have been called + * before calling this function. The transfer status should be checked + * to see if transmitter is not full before calling this function. + * @param[in] data - Data byte to write to the UART1 + * @return none + */ +void UART1_Write(uint8_t data); + +/** + * @ingroup uartdriver + * @brief Returns a boolean value if data is available to read + * @param none + * @return true - Data available to read + * @return false - Data not available to read + */ +bool UART1_IsRxReady(void); + +/** + * @ingroup uartdriver + * @brief Returns a boolean value if data can be written + * @param none + * @return true - Data can be written + * @return false - Data can not be written + */ +bool UART1_IsTxReady(void); + +/** + * @ingroup uartdriver + * @brief Indicates if all bytes have been transferred + * @param none + * @return true - All bytes transferred + * @return false - Data transfer is pending + */ +bool UART1_IsTxDone(void); + +/** + * @ingroup uartdriver + * @brief Enables UART1 transmit + * @param none + * @return none + */ +void UART1_TransmitEnable(void); + +/** + * @ingroup uartdriver + * @brief Disables UART1 transmit + * @param none + * @return none + */ +void UART1_TransmitDisable(void); + +/** + * @ingroup uartdriver + * @brief Enables or disables UART1 Auto-Baud detection + * @param[in] enable - true, starts the auto-baud detection + * @param[in] enable - false, disables the auto-baud detection + * @return none + */ +void UART1_AutoBaudSet(bool enable); + +/** + * @ingroup uartdriver + * @brief Returns the status of Auto-Baud detection + * @param none + * @return true - Auto-Baud detection in progress or counter overflow occurred + * @return false - Auto-Baud detection is complete or disabled + */ +bool UART1_AutoBaudQuery(void); + +/** + * @ingroup uartdriver + * @brief Returns enable state of the Auto-Baud feature + * @param none + * @return true - Auto-Baud is enabled + * @return false - Auto-Baud is disabled + */ +bool UART1_AutoBaudEventEnableGet(void); + +/** + * @ingroup uartdriver + * @brief Sets the BRG value of UART1 + * @param[in] baudRate - BRG value upto 20 bits + * @return none + * @note Make sure the is no transmission in progress using \ref UART1_IsTxDone function + */ +void UART1_BRGCountSet(uint32_t brgValue); + +/** + * @ingroup uartdriver + * @brief Gets the BRG value of UART1 + * @param none + * @return Combined BRG value upto 20 bits + */ +uint32_t UART1_BRGCountGet(void); + +/** + * @ingroup uartdriver + * @brief Sets the calculated Baud-Rate of UART1 + * @param[in] baudRate - Value of Baud-Rate to be set + * @return none + * @note Make sure the is no transmission in progress using \ref UART1_IsTxDone function + */ +void UART1_BaudRateSet(uint32_t baudRate); + +/** + * @ingroup uartdriver + * @brief Gets the actual Baud-Rate of UART1 + * @param none + * @return Actual baud-rate of UART1 + */ +uint32_t UART1_BaudRateGet(void); + +/** + * @ingroup uartdriver + * @brief Returns the error status of UART1 + * @param none + * @return Errors with masking as per \ref UART1_ERROR_MASKS + */ +size_t UART1_ErrorGet(void); + +#endif // UART1_H + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/uart_interface.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/uart_interface.h new file mode 100644 index 0000000..ef9eb86 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/uart_interface.h @@ -0,0 +1,127 @@ +/** + * UART Generated Driver Interface Header File + * + * @file uart_interface.h + * + * @defgroup uartdriver UART Driver + * + * @brief Universal Asynchronous Receiver Transmitter driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.7.0 + * + * @skipline @version PLIB Version 1.5.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef UART_INTERFACE_H +#define UART_INTERFACE_H + +// Section: Included Files + +#include +#include +#include +#include "uart_types.h" + +// Section: Data Type Definitions + +/** + @ingroup uartdriver + @struct UART_INTERFACE + @brief Structure containing the function pointers of UART driver +*/ +struct UART_INTERFACE{ + void (*Initialize)(void); + ///< Pointer to UARTx_Initialize e.g. \ref UART1_Initialize + + void (*Deinitialize)(void); + ///< Pointer to UARTx_Deinitialize e.g. \ref UART1_Deinitialize + + uint8_t (*Read)(void); + ///< Pointer to UARTx_Read e.g. \ref UART1_Read + + void (*Write)(uint8_t); + ///< Pointer to UARTx_Write e.g. \ref UART1_Write + + bool (*IsRxReady)(void); + ///< Pointer to UARTx_IsRxReady e.g. \ref UART1_IsRxReady + + bool (*IsTxReady)(void); + ///< Pointer to UARTx_IsTxReady e.g. \ref UART1_IsTxReady + + bool (*IsTxDone)(void); + ///< Pointer to UARTx_IsTxDone e.g. \ref UART1_IsTxDone + + void (*TransmitEnable)(void); + ///< Pointer to UARTx_TransmitEnable e.g. \ref UART1_TransmitEnable + + void (*TransmitDisable)(void); + ///< Pointer to UARTx_TransmitDisable e.g. \ref UART1_TransmitDisable + + void (*TransmitInterruptEnable)(void); + ///< Pointer to UARTx_TransmitInterruptEnable e.g. \ref UART1_TransmitInterruptEnable + + void (*TransmitInterruptDisable)(void); + ///< Pointer to UARTx_TransmitInterruptDisable e.g. \ref UART1_TransmitInterruptDisable + + void (*AutoBaudSet)(bool enable); + ///< Pointer to UARTx_AutoBaudSet e.g. \ref UART1_AutoBaudSet + + bool (*AutoBaudQuery)(void); + ///< Pointer to UARTx_AutoBaudQuery e.g. \ref UART1_AutoBaudQuery + + bool (*AutoBaudEventEnableGet)(void); + ///< Pointer to UARTx_AutoBaudEventEnableGet e.g. \ref UART1_AutoBaudEventEnableGet + + void (*BRGCountSet)(uint32_t brgValue); + ///< Pointer to UARTx_BRGCountSet e.g. \ref UART1_BRGCountSet + + uint32_t (*BRGCountGet)(void); + ///< Pointer to UARTx_BRGCOuntGet e.g. \ref UART1_BRGCountGet + + void (*BaudRateSet)(uint32_t baudRate); + ///< Pointer to UARTx_BaudRateSet e.g. \ref UART1_BaudRateSet + + uint32_t (*BaudRateGet)(void); + ///< Pointer to UARTx_BaudRateGet e.g. \ref UART1_BaudRateGet + + size_t (*ErrorGet)(void); + ///< Pointer to UARTx_ErrorGet e.g. \ref UART1_ErrorGet + + void (*RxCompleteCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_RxCompleteCallbackRegister e.g. \ref UART1_RxCompleteCallbackRegister (defined only in interrupt mode) + void (*TxCompleteCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_TxCompleteCallbackRegister e.g. \ref UART1_TxCompleteCallbackRegister (defined only in interrupt mode) + void (*TxCollisionCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_TxCollisionCallbackRegister e.g. \ref UART1_TxCollisionCallbackRegister (defined only in interrupt mode) + void (*FramingErrorCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_FramingErrorCallbackRegister e.g. \ref UART1_FramingErrorCallbackRegister (defined only in interrupt mode) + void (*OverrunErrorCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_OverrunErrorCallbackRegister e.g. \ref UART1_OverrunErrorCallbackRegister (defined only in interrupt mode) + void (*ParityErrorCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_ParityErrorCallbackRegister e.g. \ref UART1_ParityErrorCallbackRegister (defined only in interrupt mode) +}; +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/uart_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/uart_types.h new file mode 100644 index 0000000..079d35c --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/mcc_generated_files/uart/uart_types.h @@ -0,0 +1,57 @@ +/** + * UART Generated Driver Types Header File + * + * @file uart_types.h + * + * @ingroup uartdriver + * + * @brief This is the generated driver types header file for the UART driver + * + * @skipline @version Firmware Driver Version 1.7.0 + * + * @skipline @version PLIB Version 1.5.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef UART_TYPES_H +#define UART_TYPES_H + +/** + @ingroup uartdriver + @enum UART_ERROR + @brief This Enum can be used to know UART error type + using UARTx_ErrorGet function e.g. \ref UART1_ErrorGet. +*/ +enum UART_ERROR_MASKS{ + UART_ERROR_FRAMING_MASK = 0x1, + UART_ERROR_PARITY_MASK = 0x2, + UART_ERROR_RX_OVERRUN_MASK = 0x4, + UART_ERROR_TX_COLLISION_MASK = 0x8, + UART_ERROR_AUTOBAUD_OVERFLOW_MASK = 0x10, +}; + +#endif + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/nbproject/configurations.xml b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/nbproject/configurations.xml new file mode 100644 index 0000000..9c658dc --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/nbproject/configurations.xml @@ -0,0 +1,499 @@ + + + + + + + mcc_generated_files/dee/dee_dual_panel.h + mcc_generated_files/dee/dee_types.h + mcc_generated_files/dee/dee.h + + + mcc_generated_files/flash/flash_interface.h + mcc_generated_files/flash/flash_hardware_nonblocking.h + mcc_generated_files/flash/flash_nonblocking.h + mcc_generated_files/flash/flash_types.h + + + mcc_generated_files/system/traps.h + mcc_generated_files/system/system_types.h + mcc_generated_files/system/interrupt.h + mcc_generated_files/system/system.h + mcc_generated_files/system/reset_types.h + mcc_generated_files/system/dmt.h + mcc_generated_files/system/reset.h + mcc_generated_files/system/clock.h + mcc_generated_files/system/pins.h + mcc_generated_files/system/watchdog.h + mcc_generated_files/system/interrupt_types.h + + + mcc_generated_files/uart/uart_types.h + mcc_generated_files/uart/uart_interface.h + mcc_generated_files/uart/uart1.h + + + + + + + + + + mcc_generated_files/dee/src/dee_dual_panel.c + mcc_generated_files/dee/src/dee.c + + + + + mcc_generated_files/flash/src/flash_asm_nonblocking.s + mcc_generated_files/flash/src/flash_nonblocking.c + + + + + mcc_generated_files/system/src/pins.c + mcc_generated_files/system/src/traps.c + mcc_generated_files/system/src/dmt.c + mcc_generated_files/system/src/interrupt.c + mcc_generated_files/system/src/system.c + mcc_generated_files/system/src/config_bits.c + mcc_generated_files/system/src/dmt_asm.s + mcc_generated_files/system/src/reset.c + mcc_generated_files/system/src/clock.c + + + + + mcc_generated_files/uart/src/uart1.c + + + + main.c + + + Makefile + dee-dual-panel-demo-partition1.mc3 + + + Makefile + + + + localhost + dsPIC33CK256MP508 + + + pk4hybrid + XC16 + 2.10 + 3 + + + + + + + + + + + + + + + + + false + false + + + + + + + false + false + + false + + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/nbproject/project.xml b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/nbproject/project.xml new file mode 100644 index 0000000..5d5e137 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition1.X/nbproject/project.xml @@ -0,0 +1,25 @@ + + + com.microchip.mplab.nbide.embedded.makeproject + + + dee-dual-panel-demo-partition1 + d95fee3b-402f-4f47-b7bf-84b4fb09c460 + 0 + ISO-8859-1 + + ../dee-dual-panel-demo-partition2.X + + + + + default + 2 + + + + false + + + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/Makefile b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/Makefile new file mode 100644 index 0000000..fca8e2c --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/Makefile @@ -0,0 +1,113 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin +RANLIB=ranlib + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... +# WARNING: the IDE does not call this target since it takes a long time to +# simply run make. Instead, the IDE removes the configuration directories +# under build and dist directly without calling make. +# This target is left here so people can do a clean when running a clean +# outside the IDE. + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/dee-dual-panel-demo-partition2.mc3 b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/dee-dual-panel-demo-partition2.mc3 new file mode 100644 index 0000000..562e50e --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/dee-dual-panel-demo-partition2.mc3 @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Application Builder + class com.microchip.mcc.melody.module.FrameworkModule + + + Configuration Bits + class com.microchip.mcc.melody.hw.module.HardwareModule + + + DMT + class com.microchip.mcc.melody.hw.module.HardwareModule + + + FLASH + class com.microchip.mcc.melody.hw.module.HardwareModule + + + ICD + class com.microchip.mcc.melody.hw.module.HardwareModule + + + INTERNAL OSCILLATOR + class com.microchip.mcc.melody.hw.module.HardwareModule + + + INTERRUPT CORE + class com.microchip.mcc.melody.hw.module.HardwareModule + + + MAIN MANAGER + class com.microchip.mcc.melody.hw.module.HardwareModule + + + Pin Manager + class com.microchip.mcc.melody.hw.module.HardwareModule + + + RESET + class com.microchip.mcc.melody.hw.module.HardwareModule + + + UART1 + class com.microchip.mcc.melody.hw.module.HardwareModule + + + WATCHDOG + class com.microchip.mcc.melody.hw.module.HardwareModule + + + meta + class com.microchip.mcc.melody.hw.module.HardwareModule + + + module0 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module1 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module123 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module2 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module3 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module31 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module39 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module4 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module47 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module5 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module50 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module6 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module64 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module69 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module77 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module82 + class com.microchip.mcc.melody.script.module.ScriptModule + + + module90 + class com.microchip.mcc.melody.script.module.ScriptModule + + + + + + + + + {"mccDevice":{"loc":"0 0","pos":"0 0"},"systemGroup":{"loc":"0 -75","pos":"0 -75"},"module39":{"loc":"159.5 -45.5","pos":"159.5 -45.5"},"module47":{"loc":"172 0","pos":"172 0"},"module90":{"loc":"325.5 95.5","pos":"325.5 95.5"},"module123":{"loc":"172 70","pos":"172 70"}} + + + + {"userAddedModules":["module5","module4","module6","module39","module1","module0","module3","module2","module64","module31","scf-adapter/importing:16-bit Bootloader:BootloaderModule","module69","module47","scf-adapter/importing:16-bit Bootloader:ApplicationModule","module77","module90","module123","module50","module82"],"version":"CURRENT","modules":{"module5":{"scriptId":"@mchp-mcc/pic24-dspic33-clock-sib","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"pin_standard":{"interfaceId":{"name":"pin-standard","version":"^0.1.0"},"handle":{"providerId":"module4","exportId":"pin-standard"}},"clk_sib_v12":{"interfaceId":{"name":"clk_sib_v12","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"INTERNAL OSCILLATOR"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module4":{"scriptId":"@mchp-mcc/pin-content-processor","imports":{"device-meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"pin-architecture":{"interfaceId":{"name":"pin-architecture","version":"1.0.0"},"handle":{"providerId":"module3","exportId":"pin-architecture"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{"saved":{"userEditedData":{"inputPPSState":{"module39":{"UART1":{"U1RX":"RD3"}}},"cname":{"eview":{"RE5":"LED1","RE6":"LED2"}}},"rows":{"module39":{"UART1$U1TX$output":{"pins":{"RD4":{"state":"L"}}}},"pcp":{"GPIO$GPIO$input":{"pins":{"RE5":{"state":"MUL"},"RE6":{"state":"MUL"}}},"GPIO$GPIO$output":{"pins":{"RE5":{"state":"L"},"RE6":{"state":"L"}}}}}}}},"module6":{"scriptId":"@mchp-mcc/clock-16bit-driver","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"clock_16bit_config_interface":{"interfaceId":{"name":"clock-16bit-config-interface","version":"^1.1.5"},"handle":{"providerId":"module5","exportId":"clock_16bit_config_interface"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{}},"module39":{"scriptId":"@mchp-mcc/pic24-dspic33-uart-protocol-upb","imports":{"pin_standard":{"interfaceId":{"name":"pin-standard","version":"^0.1.0"},"handle":{"providerId":"module4","exportId":"pin-standard"}},"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"uart_protocol_upb_v1":{"interfaceId":{"name":"uart_protocol_upb_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"UART1"}},"clock_16bit_interface":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module5","exportId":"clock_16bit_interface"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"interrupt_service":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module1":{"scriptId":"@mchp-mcc/dspic33-configuration-bits","imports":{"dspic33_configuration_bits":{"interfaceId":{"name":"dspic33_configuration_bits","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"Configuration Bits"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{"main":{"FBOOT":{"btmodeFboot":"DUAL"},"FBTSEQ":{"bseqFbtseq":"0x003","ibseqFbtseq":"0xFFC"}}}},"module0":{"scriptId":"@mchp-mcc/main-16bit-manager","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"main":{"interfaceId":{"name":"main-16bit-manager","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"MAIN MANAGER"}}},"framewSpecificState":{"userEditedImports":[]}},"module3":{"scriptId":"@mchp-mcc/pic24-dspic33-pin-manager","imports":{"pic24-dspic33-pin-manager":{"interfaceId":{"name":"pic24-dspic33-pin-manager","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"Pin Manager"}},"device-meta":{"interfaceId":{"name":"device-meta","version":"^1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"interrupt-16bit-interface":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}},"system-16bit-initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{"adapterdata":{"pps":{"data":{"UART":{"U1RX":"RD3"},"UART1":{"U1RX":"RD3"}},"users":{"module39":{"mod_name":"UART1"}}},"cname":{"eview":{"dataMap":{"RE5":{"value":"LED1"},"RE6":{"value":"LED2"}}}}}}},"module2":{"scriptId":"@mchp-mcc/pic24-dspic33-interrupt","imports":{"int_16bit_core_v3":{"interfaceId":{"name":"int_16bit_core_v3","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"INTERRUPT CORE"}},"config_bit":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}}},"framewSpecificState":{"userEditedImports":[]},"payload":{}},"module64":{"scriptId":"@mchp-mcc/pic24-dspic33-reset","imports":{"rst_sib_v2":{"interfaceId":{"name":"rst_sib_v2","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"RESET"}}},"framewSpecificState":{"userEditedImports":[]}},"module31":{"scriptId":"@mchp-mcc/pic24-dspic33-wdt-upb-v1","imports":{"wdt_upb_16bit_v1":{"interfaceId":{"name":"wdt_upb_16bit_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"WATCHDOG"}},"clock_16bit_interface":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module5","exportId":"clock_16bit_interface"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"scf-adapter/importing:16-bit Bootloader:BootloaderModule":{"scriptId":"scf-adapter/importing:16-bit Bootloader:BootloaderModule","imports":{"boot-cantp-driver":{"interfaceId":{"name":"can-tp","version":"^1"}},"boot-uart-driver":{"interfaceId":{"name":"uart-basic-drv-interface","version":"^1||^2"}},"boot-device-meta":{"interfaceId":{"name":"device-meta-16bit-interface","version":"^1.0"}},"boot-main":{"interfaceId":{"name":"initializer-main","version":"^0.3"}},"boot-code-guard":{"interfaceId":{"name":"code-guard-16bit-interface","version":"^1.0"}},"boot-config-bits":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0"}},"boot-crypto":{"interfaceId":{"name":"crypto-auth-lib","version":"^1.1.0"}},"boot-clock":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0"}},"boot-flash":{"interfaceId":{"name":"flash-interface","version":"^1.0"}},"boot-interrupts":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.1.1-a"}},"boot-dependency-manager":{"interfaceId":{"name":"sort_childToParent","version":"^1"}}},"framewSpecificState":{"userEditedImports":[]}},"module69":{"scriptId":"@mchp-mcc/wdt-16bit-driver","imports":{"wdt_16bit_interface":{"interfaceId":{"name":"wdt-16bit-interface","version":"^1.0.1"},"handle":{"providerId":"module31","exportId":"wdt_16bit_interface"}},"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}}},"framewSpecificState":{"userEditedImports":[]}},"module47":{"scriptId":"@mchp-mcc/pic24-dspic33-nvm-ctrl-16bit-v1","imports":{"nvm_ctrl_16bit_v1":{"interfaceId":{"name":"nvm_ctrl_16bit_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"FLASH"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"interrupt_service":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"scf-adapter/importing:16-bit Bootloader:ApplicationModule":{"scriptId":"scf-adapter/importing:16-bit Bootloader:ApplicationModule","imports":{"boot-device-meta":{"interfaceId":{"name":"device-meta-16bit-interface","version":"^1.0"}},"boot-code-guard":{"interfaceId":{"name":"code-guard-16bit-interface","version":"^1.0"}},"boot-config-bits":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0"}},"boot-clock":{"interfaceId":{"name":"clock-16bit-interface","version":"^1.0"}},"boot-flash":{"interfaceId":{"name":"flash-interface","version":"^1.0"}},"boot-interrupts":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.1.1-a"}}},"framewSpecificState":{"userEditedImports":[]}},"module77":{"scriptId":"@mchp-mcc/icd-16bit-driver","imports":{"icd_v7":{"interfaceId":{"name":"icd_v7","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"ICD"}},"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"pin_standard":{"interfaceId":{"name":"pin-standard","version":"^0.1.0"},"handle":{"providerId":"module4","exportId":"pin-standard"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module90":{"scriptId":"@mchp-mcc/uart-driver","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"^1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"uart_basic":{"interfaceId":{"name":"uart-basic","version":"^6.0.0"},"handle":{"providerId":"module39","exportId":"uart_basic","label":"UART1"}}},"framewSpecificState":{"userEditedImports":["uart_basic"]}},"module123":{"scriptId":"@mchp-mcc/16bit_data_eeprom_emulation","imports":{"initializer_main":{"interfaceId":{"name":"initializer-main","version":"^0.3.0"},"handle":{"providerId":"module0","exportId":"initializer_main"}},"flash_interface":{"interfaceId":{"name":"flash-interface","version":"^1.3.1"},"handle":{"providerId":"module47","exportId":"flash_interface"}},"project_properties":{"interfaceId":{"name":"project-properties","version":"1.0.1"},"handle":{"providerId":"com.microchip.mcc.melody.adapter.ProjectConfigurationAdapter","exportId":"project-properties"}}},"framewSpecificState":{"userEditedImports":[]}},"module50":{"scriptId":"@mchp-mcc/pic24-dspic33-dmt-upb","imports":{"wdt_dmt_upb_v1":{"interfaceId":{"name":"wdt_dmt_upb_v1","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"DMT"}},"system_16bit_initializer":{"interfaceId":{"name":"system-16bit-initializer","version":"^1.0.0"},"handle":{"providerId":"module0","exportId":"system_16bit_initializer"}},"interrupt_service":{"interfaceId":{"name":"interrupt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module2","exportId":"interrupt_16bit_interface"}},"config_16bit_interface":{"interfaceId":{"name":"config-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module1","exportId":"config_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}},"module82":{"scriptId":"@mchp-mcc/dmt-16bit-driver","imports":{"device_meta":{"interfaceId":{"name":"device-meta","version":"1.0.0"},"handle":{"providerId":"mccDevice","exportId":"meta"}},"dmt_16bit_interface":{"interfaceId":{"name":"dmt-16bit-interface","version":"^1.0.0"},"handle":{"providerId":"module50","exportId":"dmt_16bit_interface"}}},"framewSpecificState":{"userEditedImports":[]}}},"content":{"@mchp-mcc/pic-16bit":"5.11.2","@mchp-mcc/16bit_data_eeprom_emulation":"2.1.0","@mchp-mcc/wdt-16bit-driver":"1.0.7","@mchp-mcc/clock-16bit-driver":"1.2.1","@mchp-mcc/pic24-dspic33-dmt-upb":"1.1.1","@mchp-mcc/pic24-dspic33-reset":"1.1.0","@mchp-mcc/pic24-dspic33-clock-sib":"1.4.2","@mchp-mcc/dmt-16bit-driver":"1.0.6","@mchp-mcc/main-16bit-manager":"1.1.2","@mchp-mcc/dspic33-configuration-bits":"1.2.2","@mchp-mcc/pin-content-processor":"3.8.0","@mchp-mcc/pic24-dspic33-wdt-upb-v1":"1.2.0","@mchp-mcc/icd-16bit-driver":"1.0.3","@mchp-mcc/pic24-dspic33-interrupt":"1.3.1","@mchp-mcc/pic24-dspic33-nvm-ctrl-16bit-v1":"3.2.1","@mchp-mcc/uart-driver":"1.9.0","@mchp-mcc/pic24-dspic33-pin-manager":"1.3.0","@mchp-mcc/pic24-dspic33-uart-protocol-upb":"1.5.0"}} + + + + + mcc_generated_files\system\watchdog.h + c78d82c6a93f94e2ca7ff8d5a00751d4875fe8f76a564bf5ee672dec7b2fcecd + + + mcc_generated_files\uart\uart1.h + 9d96368e37b8d7696208b70144ee68468bc9dbd10d7b6e280fbb8e32576fb5f7 + + + mcc_generated_files\dee\dee.h + c7604c01517966eb9a640fc7deb5600bd42f358ab134ab62e17ebd8a4648541c + + + mcc_generated_files\system\interrupt.h + 6464b4341a8eaff2e988ffcd845177680e4875f9df99e92bd47057c8ca2f3b10 + + + mcc_generated_files\system\dmt.h + 57d16baa46d9112194e4062405aa45d38de8ed05abc6bc8acbd04d119c2ceaad + + + mcc_generated_files\system\pins.h + 13d66373f1bdcb0bc074eebe59466e1521dfaeacc1a9e171d4888789bdafe188 + + + mcc_generated_files\system\reset_types.h + d191b15996f8e881c5733de5e156e79d7c259fc3fbc8acb2a69a1c66b7492a30 + + + mcc_generated_files\system\interrupt_types.h + fcc4de703d90fc68834c25256201876534d34d74ba76f364853f083b25af5e64 + + + mcc_generated_files\system\src\pins.c + c2b1d073f4adcd5c960f775c72181477f15411b3d8bcaeed8b796a51fcdae533 + + + mcc_generated_files\system\src\dmt.c + 6529950f685b878b2152214e3eb83a956b3f2a12f56ba5b007c0c925ca962203 + + + mcc_generated_files\flash\flash_interface.h + a509b006ad301ebd6295285d4a0019c95a1aad5177225c92d1757b44e40d35cf + + + mcc_generated_files\uart\uart_interface.h + 5ba1f66ca45ceabad47ad42f239110f461a813317896625fae77f75b8e497afe + + + mcc_generated_files\uart\uart_types.h + b2eeabb3cdfd2d14482487bc0dde1a44ad910e074ac930f119ae17a3917c9c25 + + + mcc_generated_files\system\src\clock.c + 13249a24dae8acb448d98503d22c1360ef6c78eeff6a251ec17605d62065dc91 + + + mcc_generated_files\system\clock.h + 4428ec5c7fd48ca6d478a0d10d9e2b6fbd43d8af642d54e2830a70e6f9188edc + + + mcc_generated_files\system\reset.h + 648b2215a7dac788776692bcda2f20dd9806e35bf264bbb985f74affce313a5b + + + mcc_generated_files\flash\flash_types.h + 02f07141ec0ba53f523241cdca2cdd04599fdd80534670ff7ce67efd0f63d6c8 + + + mcc_generated_files\dee\dee_dual_panel.h + c471d3d894c241d8fbbf0777d3aa3b411620d4ff08b8dd5be38f8690bda678b6 + + + mcc_generated_files\dee\src\dee.c + f45c0aee6c8d6ff829cc505ee4729adbf1ca25f3d9cb852ca781ed0ccbf26081 + + + mcc_generated_files\flash\flash_hardware_nonblocking.h + d839bb8ec94215a85a91ae687c8019d749da08ed2924337d176d50729d87c5b9 + + + mcc_generated_files\system\src\reset.c + 90dd98db9464e22649e22e199e8d09d0b9720f6db1cd323c4a8fa956f0586f7b + + + mcc_generated_files\system\system.h + 7452d3b6bf4948ef0e0d63e9e76c5df987903b63b35cc5572be4abb0ae834d15 + + + mcc_generated_files\flash\src\flash_nonblocking.c + 6fc92225cebce64409b1b7b0a9cd26a8b3be7c29030608fdbd4889678cc27211 + + + main.c + bc16a079de30cf6e1f09bbc022097c0021210f08dfc6993e83a1c8b9d8d84ba3 + + + mcc_generated_files\dee\dee_types.h + 174f5e9e9e417c2cb107f530e573a63787b70bd17b77c35a5135186d682b7087 + + + mcc_generated_files\uart\src\uart1.c + 1b721de5715dca5b68bb3a2c6c9d983e93c6891a9ea18ef34bf93be2e05d3e25 + + + mcc_generated_files\flash\src\flash_asm_nonblocking.s + 073e7aab7cdff27a62a55865db2cbf34def0061af0b771717c8e31dade11d6d3 + + + mcc_generated_files\system\src\interrupt.c + 005b73d1475a4935cb8062e3894d4941470c9b405191e2acc729d065a29c0715 + + + mcc_generated_files\system\src\dmt_asm.s + 5627e95412796e39593ab9b1f020a5841f08366fe97dd93bb412bce56643b07c + + + mcc_generated_files\system\src\traps.c + c79aa8c466de788e95471c3a734f4cd2f452b06ba0aa7f0a457bc1c9adefdceb + + + mcc_generated_files\system\src\config_bits.c + 280db573397c8b656b202894e02555b0015014eafff8c282ff6729ece170dffe + + + mcc_generated_files\dee\src\dee_dual_panel.c + ef7b7e1912e4f71015eeafac0d3859501dbfc235ab66c9389e0e7592bd49f08c + + + mcc_generated_files\system\traps.h + 900429a7d683726be69419a799bcdcc8b61c07933d2a0bb76d7abfb097554f74 + + + mcc_generated_files\system\system_types.h + 516f383ecaa24baa7fcc0787fb7897e48562adbaf8b80ce159de37ff831b1287 + + + mcc_generated_files\system\src\system.c + 81c63bff23835a81c9bc017be002fb600b5aa36ba31014b20fa2e90a5c0eeabd + + + mcc_generated_files\flash\flash_nonblocking.h + b4bbd52f06bd27893fe8976dfa3cc1f841a6ca4c1e31507f071fa487b5644d4a + + + \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/main.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/main.c new file mode 100644 index 0000000..821b6ea --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/main.c @@ -0,0 +1,79 @@ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ +#include "mcc_generated_files/dee/dee.h" +#include "mcc_generated_files/system/system.h" +#include "mcc_generated_files/system/pins.h" +#include +#include + +#define EXPECTED_VALUE_AT_ADDR0 1024 +#define EXPECTED_VALUE_AT_ADDR1 1025 +#define EXPECTED_UPDATED_VALUE_AT_ADDR2 513 +#define EXPECTED_VALUE_AT_ADDR3 514 +#define EXPECTED_VALUE_AT_ADDR4 515 +/* + Main application +*/ + +int main(void) +{ + uint16_t addr0 = 0, addr1 = 1, addr2 = 2, addr3 = 3, addr4 = 4, i; + uint16_t valueAtAddr0 = 0; + uint16_t valueAtAddr1 = 0; + uint16_t valueAtAddr2 = 0; + uint16_t valueAtAddr3 = 0; + uint16_t valueAtAddr4 = 0; + SYSTEM_Initialize(); + printf("************* Application in Partition2 starts *******************\r\n"); + DEE_Init(); + + DEE_Read(addr0, &valueAtAddr0); + DEE_Read(addr1, &valueAtAddr1); + + if (valueAtAddr0 == EXPECTED_VALUE_AT_ADDR0 && valueAtAddr1 == EXPECTED_VALUE_AT_ADDR1) { + LED1_SetHigh(); + printf("DEE Data comparison from previous iteration is successful.\r\n Value at address 0 is %d\r\n Value at address 1 is %d\r\n", valueAtAddr0, valueAtAddr1); + } else { + printf("DEE Data comparison from previous iteration is failed.\r\n Value at address 0 is %d\r\n Value at address 1 is %d\r\n", valueAtAddr0, valueAtAddr1); + } + printf("Address 2 value will be updated by Application in Partition2.\r\n"); + + for (i = 0; i < 512; i++) { + DEE_Write(addr2, i + 2); + DEE_Write(addr3, i + 3); + DEE_Write(addr4, i + 4); + } + + + DEE_Read(addr2, &valueAtAddr2); + DEE_Read(addr3, &valueAtAddr3); + DEE_Read(addr4, &valueAtAddr4); + + if (valueAtAddr2 == EXPECTED_UPDATED_VALUE_AT_ADDR2 && valueAtAddr3 == EXPECTED_VALUE_AT_ADDR3 && valueAtAddr4 == EXPECTED_VALUE_AT_ADDR4) { + LED1_SetHigh(); + printf("Data EEPROM Emulation successful.\r\n Value at address 2 is %d\r\n Value at address 3 is %d\r\n Value at address 4 is %d\r\n", valueAtAddr2, valueAtAddr3, valueAtAddr4); + } else { + printf("Data EEPROM Emulation failed.\r\n Value at address 2 is %d\r\n Value at address 3 is %d\r\n Value at address 4 is %d\r\n", valueAtAddr2, valueAtAddr3, valueAtAddr4); + } + + printf("************* Application in Partition2 ends *******************\r\n"); + while(1); +} \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee.h new file mode 100644 index 0000000..e98cade --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee.h @@ -0,0 +1,105 @@ +/** + DEE Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + dee.h + + @Summary + This is the generated header file for the DEE library using Melody Code Configurator + + @Description + This header file provides APIs for library DEE. + The generated drivers are tested against the following: +*/ + +#ifndef DEE_H +#define DEE_H + +#include +#include + +typedef enum{ + DEE_NO_ERROR, + DEE_EXPIRED_PAGE, + DEE_PACK_BEFORE_PAGE_FULL, + DEE_PACK_BEFORE_INIT, + DEE_PACK_SKIPPED, + DEE_ILLEGAL_ADDRESS, + DEE_PAGE_CORRUPT, + DEE_WRITE_ERROR, + DEE_READ_ERROR, +}DEE_RETURN_STATUS; + + +/** + @Summary + This function initializes all of the EEPROM banks + + @Description + This routine finds an unexpired page to become an active page. It then + counts the number of active pages. If no active pages are found, the + first unexpired page is initialized for emulation. If one active page is + found, it is assumes a reset occurred and the function does nothing. If + two active pages are found, it is assumes a reset occurred during a pack. + The second page is erased and a pack is called. If three, an error code + is returned as the allocated memory is assumed to be corrupted. This + function must be called prior to any other operation. + + @Param + None. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_Init(void); + +/** + @Summary + This function is used to retrieve data EEPROM information. + + @Description + This routine verifies the address is valid. If not, the Illegal Address + flag is set and return DEE_ILLEGAL_ADDRESS. It then finds the active page,if an + active page can not be found, the Page Corrupt status bit is set and + DEE_PAGE_CORRUPT is returned. A reverse search of the active page attempts to find + the matching address in the program memory MSB (odd address). If a match + is found, the corresponding data EEPROM data (even address) is returned, + otherwise DEE_READ_ERROR is returned. This function can be called by the user. + + @Param + Data EE address and pointer to hold the read flash data. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_Read(uint16_t address, uint16_t *data); + +/** + @Summary + This function is used to write emulated data EEPROM. + + @Description + This routine verifies the address is valid. If not, the Illegal Address + flag is set and an error code is returned. It then finds the active page. + If an active page can not be found, the Page Corrupt status bit is set + and an error code is returned. A read is performed, if the data was not + changed, the function exits. If the last location is programmed, the Pack + Skipped error flag is set (one location should always be available). The + data EE information (MSB = address, LSW = data) is programmed and + verified. If the verify fails, the Write Error flag is set. If the write + went into the last location of the page, pack is called. This function + can be called by the user. + + @Param + Data EE address and data to be written. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_Write(uint16_t address, uint16_t data); + + +#endif /* DEE_H */ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee_dual_panel.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee_dual_panel.h new file mode 100644 index 0000000..9a23fca --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee_dual_panel.h @@ -0,0 +1,55 @@ +/** + DEE Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + dee_helper.h + + @Summary + This is the generated header file for the DEE library using Melody Code Configurator + + @Description + This header file provides APIs for library DEE. + The generated drivers are tested against the following: +*/ + +#ifndef DEE_HELPER_H +#define DEE_HELPER_H + +#include "dee.h" + +/** + @Summary + This function initializes all of the EEPROM banks + + @Description + This functions performs the same functionality as DEE_Init() , but this function works on the + active partition in devices with dual partition support. + + @Param + None. + + @Returns + Returns DEE_RETURN_STATUS +*/ +DEE_RETURN_STATUS DEE_ActivePartitionInit(void); + +/** + @Summary + This function copies the DEE data from active partition to in-active partition + + @Description + This function initializes the DEE data structure in the active partition and check if there is any data available + in the active partition from the previous execution if so it copies the data to the inactive partition. + + @Param + None. + + @Returns + Returns True or False. +*/ +bool DEE_ActiveToInactivePartitionDataCopy(void); + +#endif /* DEE_HELPER_H */ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee_types.h new file mode 100644 index 0000000..5b33ed8 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/dee_types.h @@ -0,0 +1,93 @@ +/** + DEE Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + dee_types.h + + @Summary + This is the generated header file for the DEE library using Melody Code Configurator + + @Description + This header file provides APIs for library DEE. + The generated drivers are tested against the following: +*/ + +#ifndef DEE_TYPES_H +#define DEE_TYPES_H + +#define DATA_EE_BANKS 1 +#define DATA_EE_SIZE 255 +#define DATA_EE_TOTAL_SIZE (DATA_EE_BANKS * DATA_EE_SIZE) +#define NUM_DATA_EE_PAGES 2 +#define NUMBER_OF_INSTRUCTIONS_IN_PAGE 1024 +#define NUMBER_OF_INSTRUCTIONS_IN_ROW 128 +// If the device has ECC +#define __HAS_ECC 1 +#define ERASE_WRITE_CYCLE_MAX 10000 +#define NUMBER_OF_ROWS_IN_PAGE (_FLASH_PAGE / _FLASH_ROW) +#define PAGE_AVAILABLE 1 +#define PAGE_CURRENT 0 +#define PAGE_EXPIRED 0 +#define PAGE_NOT_AVAILABLE 0 +#define PAGE_NOT_CURRENT 1 +#define PAGE_NOT_EXPIRED 1 +#define STATUS_AVAILABLE 18 +#define STATUS_CURRENT 19 +#define STATUS_EXPIRED 20 +#define ERASE_STATE 0xFFFFFF +#define DEE_STATUS_MASK 0xE3 +#define PACKED_PAGE_DATA_SIZE 0x100 +#define MAX_DATA_SIZE_PER_PAGE 0xFF +#define DEE_ADDRESS_MASK 0x00FF0000 +#define WRITE_RETRY_COUNT 2 +#define FLASH_WORD_WRITE_SIZE 2 +#define DEE_START_ADDRESS_INACTIVE_PARTITION 0x414800 +#define DEE_START_ADDRESS_ACTIVE_PARTITION 0x14800 + +/*Data EE info stored in PM in following format + Status in first two locations of PM page, + 8-bit DEE Address (odd address, low byte) 16-bit DEE data (even address)*/ +#define BYTES_PER_DATA_EE 2 +#define DEE_BANK_SIZE (NUMBER_OF_INSTRUCTIONS_IN_PAGE * BYTES_PER_DATA_EE * NUM_DATA_EE_PAGES) +#define DEE_PAGE_SIZE (NUMBER_OF_INSTRUCTIONS_IN_PAGE * BYTES_PER_DATA_EE) +#define DEE_DATA_SIZE_IN_BYTES (DATA_EE_BANKS * NUM_DATA_EE_PAGES * NUMBER_OF_INSTRUCTIONS_IN_PAGE * BYTES_PER_DATA_EE) + + +typedef union +{ + uint8_t val; + struct + { + unsigned addrNotFound:1; + unsigned expiredPage:1; + unsigned packBeforePageFull:1; + unsigned packBeforeInit:1; + unsigned packSkipped:1; + unsigned IllegalAddress:1; + unsigned pageCorrupt:1; + unsigned writeError:1; + }; +} DATA_EE_FLAGS; + + +// User constant validation +#if DATA_EE_BANKS == 0 + #error Minimum data EE banks is 1 +#endif + +#if DATA_EE_SIZE > 255 + #error Maximum data EE size is 255 +#endif + +#if NUM_DATA_EE_PAGES < 2 + #error Minimum number of program memory pages is 2 +#endif + +#if ERASE_WRITE_CYCLE_MAX > 65535 + #error Maximum number of erase/write cycles is 65,535 +#endif + +#endif /* DEE_TYPES_H */ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/src/dee.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/src/dee.c new file mode 100644 index 0000000..8a246a8 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/src/dee.c @@ -0,0 +1,582 @@ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include +#include "../../flash/flash_nonblocking.h" +#include "../dee.h" +#include "../dee_types.h" +#include "../dee_dual_panel.h" + +/*Data EE info stored in PM in following format + Status in first two locations of PM page, + 8-bit DEE Address (odd address, low byte) 16-bit DEE data (even address)*/ +uint8_t emulationPages[DEE_DATA_SIZE_IN_BYTES] + __attribute__ ((space(psv), address(DEE_START_ADDRESS_INACTIVE_PARTITION), aligned(NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2), noload)); +#define DEE_PAGE_ADDRESS(bank, page) ((__builtin_tbladdress(&emulationPages) + (DEE_BANK_SIZE * (bank)) + (DEE_PAGE_SIZE * (page))) & 0xFFFFFF) + +#define GetAddrNotFound() dataEEFlags.addrNotFound +#define SetAddrNotFound(x) dataEEFlags.addrNotFound = x +#define GetPageCorruptStatus() dataEEFlags.pageCorrupt +#define SetPageCorruptStatus(x) dataEEFlags.pageCorrupt = x +#define GetPageExpiredPage() dataEEFlags.expiredPage +#define SetPageExpiredPage(x) dataEEFlags.expiredPage = x +#define GetPageIllegalAddress() dataEEFlags.IllegalAddress +#define SetPageIllegalAddress(x) dataEEFlags.IllegalAddress = x +#define GetPagePackBeforeInit() dataEEFlags.packBeforeInit +#define SetPagePackBeforeInit(x) dataEEFlags.packBeforeInit = x +#define GetPagePackBeforePageFull() dataEEFlags.packBeforePageFull +#define SetPagePackBeforePageFull(x) dataEEFlags.packBeforePageFull = x +#define GetPagePackSkipped() dataEEFlags.packSkipped +#define SetPagePackSkipped(x) dataEEFlags.packSkipped = x +#define GetPageWriteError() dataEEFlags.writeError +#define SetPageWriteError(x) dataEEFlags.writeError = x + +DATA_EE_FLAGS dataEEFlags; + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field); +static void ErasePage(uint8_t bank, uint8_t page); +static uint16_t GetNextAvailCount(uint8_t bank); +static DEE_RETURN_STATUS DEE_Pack(uint8_t bank); +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey); +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data); +static DEE_RETURN_STATUS DEE_Initialize(void); + +static void FlashEraseOpHandler(void* context) { + // Doing nothing +} + +static void FlashProgramOpHandler(void *context) { + // Doing nothing +} + +DEE_RETURN_STATUS DEE_Init(void) +{ + DEE_RETURN_STATUS deeReturnStatus = DEE_NO_ERROR; + deeReturnStatus = DEE_ActivePartitionInit(); + if(deeReturnStatus == DEE_NO_ERROR) + { + bool dataCopied = DEE_ActiveToInactivePartitionDataCopy(); + if(!dataCopied) + { + deeReturnStatus = DEE_Initialize(); + } + } + return deeReturnStatus; +} + +DEE_RETURN_STATUS DEE_Initialize(void) +{ + uint8_t pageCnt; + uint16_t erasePage; + uint16_t currentPage; + uint32_t pageAddress; + uint8_t bank; + uint32_t statusWord[2]; + + dataEEFlags.val = 0; + for (bank = 0; bank < DATA_EE_BANKS; bank++) + { + pageCnt = 0; + erasePage = 0; + + // Find unexpired page + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_EXPIRED) == PAGE_EXPIRED); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - All pages expired + } + // Count active page(s). + for (currentPage = 0; currentPage < NUM_DATA_EE_PAGES; currentPage++) + { + if (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_CURRENT) + { + pageCnt++; + } + } + //If no active pages found, initialize page 0 + if (pageCnt == 0) + { + ErasePage(bank, 0); + pageAddress = DEE_PAGE_ADDRESS(bank, 0); + //New page: unavailable, active, reset count + statusWord[0] = 0xF3; + statusWord[0] = statusWord[0] << 16; + statusWord[1] = ERASE_STATE; + DEE_FlashWrite(pageAddress, statusWord, FLASH_UNLOCK_KEY); + continue; + } + //If one active page, do nothing + else if (pageCnt == 1) + { + continue; + } + //If two active pages, erase second and repack first + else if (pageCnt == 2) + { + if ((GetPageStatus(bank, NUM_DATA_EE_PAGES - 1, STATUS_CURRENT) == PAGE_CURRENT) && + (GetPageStatus(bank, 0, STATUS_CURRENT) == PAGE_CURRENT)) + { + currentPage = NUM_DATA_EE_PAGES - 1; + erasePage = 0; + } + else + { + currentPage = 0; + while ((GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT) && + (currentPage < NUM_DATA_EE_PAGES)) + { + currentPage++; + } + erasePage = currentPage + 1; + if (erasePage == NUM_DATA_EE_PAGES) + { + erasePage = 0; + } + } + ErasePage(bank, erasePage); + if (!GetNextAvailCount(bank)) + { + DEE_Pack(bank); + } + continue; + } + else + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); + } + } + return (DEE_NO_ERROR); +} + +DEE_RETURN_STATUS DEE_Read(uint16_t addr, uint16_t* dataRead) +{ + uint16_t currentPage; + uint32_t pageAddress; + uint8_t latchAddr; + uint16_t i; + uint8_t bank; + uint32_t latchAddrData; + + if (addr >= DATA_EE_TOTAL_SIZE) + { + SetPageIllegalAddress(1); + return (DEE_ILLEGAL_ADDRESS); + } + + bank = addr / DATA_EE_SIZE; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); // Error - no active page + } + + pageAddress = DEE_PAGE_ADDRESS(bank, (currentPage + 1)) - 4; + + i = NUMBER_OF_INSTRUCTIONS_IN_PAGE; + + do + { + DEE_FlashRead(pageAddress, 1, &latchAddrData); + latchAddr = (latchAddrData >> 16) & 0xFF; + pageAddress -= 4; // Skip over preceding odd address in devices with ECC or double word writes + i -= 2; + } + while ((i > 0) && (latchAddr != (addr % DATA_EE_SIZE))); + + if (!i) + { + SetAddrNotFound(1); + return (DEE_ILLEGAL_ADDRESS); + } + + pageAddress += 4; // Adjust offset to skip the odd word + + DEE_FlashRead(pageAddress, 1, &latchAddrData); + //Extract the data(lower 16 bits) + *dataRead = latchAddrData & 0xFFFF; + return (DEE_NO_ERROR); +} + +DEE_RETURN_STATUS DEE_Write(uint16_t addr, uint16_t data) +{ + uint16_t currentPage; + uint32_t pageAddress; //Current array (page) offset of selected element (PM 16-bit word) + uint16_t nextLoc; + volatile uint16_t latchData; + volatile uint8_t latchAddr; + uint8_t dataEEFlags_sh; + uint16_t bank; + uint16_t pageToBeErased; + uint32_t deeItem[2]; + + if (addr >= DATA_EE_TOTAL_SIZE) + { + SetPageIllegalAddress(1); + return (DEE_ILLEGAL_ADDRESS); + } + + bank = addr / DATA_EE_SIZE; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); // Error - no active page + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + + nextLoc = GetNextAvailCount(bank); + + if (!nextLoc) + { + pageToBeErased = currentPage + 1; + if(pageToBeErased == NUM_DATA_EE_PAGES) + { + pageToBeErased = 0; + } + ErasePage(bank, pageToBeErased); + DEE_Pack(bank); + + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); // Error - no active page + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + nextLoc = GetNextAvailCount(bank); + } + + dataEEFlags_sh = dataEEFlags.val; + //Do not write data if it did not change + uint16_t dataRead; + DEE_Read(addr, &dataRead); + if (dataRead == data) + { + if (GetAddrNotFound() == 0) // Check if the read was successful + { + dataEEFlags.val = dataEEFlags_sh; + return (DEE_NO_ERROR); + } + } + dataEEFlags.val = dataEEFlags_sh; //Restore status flags + + pageAddress = pageAddress + nextLoc; + + deeItem[0] = addr % DATA_EE_SIZE; + deeItem[0] = (deeItem[0] << 16) | data; + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(pageAddress, deeItem, FLASH_UNLOCK_KEY); + + Nop(); + Nop(); + + DEE_FlashRead(pageAddress, 1, &deeItem[0]); + latchData = (deeItem[0] & 0xFFFF); + + if (latchData != (data & 0xFFFF)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - RAM does not match PM + } + + latchAddr = ((deeItem[0] >> 16) & 0xFF); + + if (latchAddr != (addr % DATA_EE_SIZE)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - RAM does not match PM + } + + //Pack if page is full + if ((nextLoc + 4) == ((NUMBER_OF_INSTRUCTIONS_IN_PAGE) * 2)) + { + DEE_Pack(bank); + } + + return (DEE_NO_ERROR); +} + +static DEE_RETURN_STATUS DEE_Pack(uint8_t bank) +{ + uint16_t currentPage; //Array row (PM page) of active DEE page + uint16_t packedPage; //Array row (PM page) of packed page + uint32_t currentPageAddress; //Current page address + uint32_t packedPageAddress; //Packed page address + uint16_t latchAddr; + uint16_t latchData; + uint8_t dataEEFlags_sh; + uint32_t deeItem[2]; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPagePackBeforeInit(1); + return (DEE_PACK_BEFORE_INIT); // Error - no active page + } + else + { + // Find the next unexpired page to use + packedPage = currentPage + 1; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + while (GetPageStatus(bank, packedPage, STATUS_EXPIRED) == PAGE_EXPIRED) + { + packedPage++; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + if (packedPage == currentPage) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - all pages expired + } + } + } + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + if (GetNextAvailCount(bank)) + { + SetPagePackBeforePageFull(1); // Pack called before the page was full + } + + dataEEFlags_sh = dataEEFlags.val; + SetAddrNotFound(0); // Initialize flag + + + deeItem[0] = ERASE_STATE; + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on dsPIC33E devices with ECC or double word writes + latchAddr = 0; + + do + { + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &latchData); + if (GetAddrNotFound()) //if address is unwritten, skip to next address + { + SetAddrNotFound(0); + } + else + { + deeItem[0] = latchAddr; + deeItem[0] = ((deeItem[0] << 16) | (latchData & 0xFFFF)); + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + latchAddr++; + } + while (latchAddr != DATA_EE_SIZE); + + dataEEFlags.val = dataEEFlags_sh; //Restore status flags + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage) + 4; // Adjust offset to skip the odd word + + uint32_t data; + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + + while (latchAddr != 0xFF) + { + uint16_t dataRead; + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &dataRead); + if (dataRead != latchData) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - data does not match + } + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) &0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + + //Program page status + currentPageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + DEE_FlashRead(currentPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + + if (packedPage == 0) + { + latchData++; //Increment E/W counter + } + + if (latchData >= ERASE_WRITE_CYCLE_MAX - 1) + { + SetPageExpiredPage(1); + latchAddr &= 0xEF; + } + + uint32_t dataItem[2]; + dataItem[0] = latchAddr; + dataItem[0] = (dataItem[0] << 16) | latchData; + dataItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, dataItem, FLASH_UNLOCK_KEY); + DEE_FlashRead(packedPageAddress, 1, &data); + uint16_t readAddr = (data >> 16) & 0xFF; + uint16_t readData = data & 0xFFFF; + + if ((latchAddr != readAddr) || + (latchData != readData)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); + } + + //Erase active page + ErasePage(bank, currentPage); + + return (GetPageExpiredPage()); +} + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field) +{ + uint32_t pageAddress; + uint8_t statusByte; + uint8_t status; + uint32_t statusInfo; + + pageAddress = DEE_PAGE_ADDRESS(bank, page); + DEE_FlashRead(pageAddress, 1, &statusInfo); + statusByte = statusInfo >> 16 & 0xFF; + switch (field) + { + case STATUS_AVAILABLE: + status = ((statusByte & 4) >> 2); + break; + case STATUS_CURRENT: + status = ((statusByte & 8) >> 3); + break; + case STATUS_EXPIRED: + status = ((statusByte & 16) >> 4); + break; + default: + status = 0; + break; + } + return (status); +} + +static void ErasePage(uint8_t bank, uint8_t page) +{ + uint32_t pageAddress = DEE_PAGE_ADDRESS(bank, page); + FLASH_NonBlockingPageErase(pageAddress, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); + return; +} + +static uint16_t GetNextAvailCount(uint8_t bank) +{ + uint16_t nextAvailCount = 0; + uint16_t currentPage; + uint8_t dataEEval; + uint32_t pageAddress; + uint32_t latchAddrData; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + + do + { + nextAvailCount += 4; + pageAddress += 4; + DEE_FlashRead(pageAddress, 1, &latchAddrData); + dataEEval = (latchAddrData >> 16) & 0xFF; + } + while ((nextAvailCount < NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) && (dataEEval != 0xFF)); + + if (nextAvailCount == NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) + { + nextAvailCount = 0; + } + return (nextAvailCount); +} + +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey) +{ + FLASH_NonBlockingWordWrite(flashAddress, data, unlockKey, FlashProgramOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); +} + +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data) +{ + while(FLASH_NonBlockingRead(flashAddress, count, data) == FLASH_OP_BUSY); +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/src/dee_dual_panel.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/src/dee_dual_panel.c new file mode 100644 index 0000000..4d21f58 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/dee/src/dee_dual_panel.c @@ -0,0 +1,532 @@ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include +#include "../../flash/flash_nonblocking.h" +#include "../dee.h" +#include "../dee_types.h" + +/*Data EE info stored in PM in following format + Status in first two locations of PM page, + 8-bit DEE Address (odd address, low byte) 16-bit DEE data (even address)*/ +uint8_t activePartitionEmulationPages[DEE_DATA_SIZE_IN_BYTES] + __attribute__ ((space(psv), address(DEE_START_ADDRESS_ACTIVE_PARTITION), aligned(NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2), noload)); +#define DEE_PAGE_ADDRESS(bank, page) ((__builtin_tbladdress(&activePartitionEmulationPages) + (DEE_BANK_SIZE * (bank)) + (DEE_PAGE_SIZE * (page))) & 0xFFFFFF) + +#define GetAddrNotFound() activePartitionDataEEFlags.addrNotFound +#define SetAddrNotFound(x) activePartitionDataEEFlags.addrNotFound = x +#define GetPageCorruptStatus() activePartitionDataEEFlags.pageCorrupt +#define SetPageCorruptStatus(x) activePartitionDataEEFlags.pageCorrupt = x +#define GetPageExpiredPage() activePartitionDataEEFlags.expiredPage +#define SetPageExpiredPage(x) activePartitionDataEEFlags.expiredPage = x +#define GetPageIllegalAddress() activePartitionDataEEFlags.IllegalAddress +#define SetPageIllegalAddress(x) activePartitionDataEEFlags.IllegalAddress = x +#define GetPagePackBeforeInit() activePartitionDataEEFlags.packBeforeInit +#define SetPagePackBeforeInit(x) activePartitionDataEEFlags.packBeforeInit = x +#define GetPagePackBeforePageFull() activePartitionDataEEFlags.packBeforePageFull +#define SetPagePackBeforePageFull(x) activePartitionDataEEFlags.packBeforePageFull = x +#define GetPagePackSkipped() activePartitionDataEEFlags.packSkipped +#define SetPagePackSkipped(x) activePartitionDataEEFlags.packSkipped = x +#define GetPageWriteError() activePartitionDataEEFlags.writeError +#define SetPageWriteError(x) activePartitionDataEEFlags.writeError = x + +DATA_EE_FLAGS activePartitionDataEEFlags; + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field); +static void ErasePage(uint8_t bank, uint8_t page); +static uint16_t GetNextAvailCount(uint8_t bank); +static DEE_RETURN_STATUS DEE_ActivePartitionPack(uint8_t bank); +static bool DEE_IsDataCopyRequired(); +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey); +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data); +static void DEE_RetryDataWrite(flash_adr_t destAddr, flash_data_t *packedPageData); +static void DEE_PackedDataGet(flash_data_t *fullPageData, uint32_t fullPageDataSize, flash_data_t *packedPageData); + +static void FlashEraseOpHandler(void* context) { + // Doing nothing +} + +static void FlashProgramOpHandler(void *context) { + // Doing nothing +} + + +DEE_RETURN_STATUS DEE_ActivePartitionInit(void) +{ + uint8_t pageCnt; + uint16_t erasePage; + uint16_t currentPage; + uint32_t pageAddress; + uint8_t bank; + uint32_t statusWord[2]; + + activePartitionDataEEFlags.val = 0; + for (bank = 0; bank < DATA_EE_BANKS; bank++) + { + pageCnt = 0; + erasePage = 0; + + // Find unexpired page + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_EXPIRED) == PAGE_EXPIRED); + currentPage++) + { + } + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - All pages expired + } + // Count active page(s). + for (currentPage = 0; currentPage < NUM_DATA_EE_PAGES; currentPage++) + { + if (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_CURRENT) + { + pageCnt++; + } + } + //If no active pages found, initialize page 0 + if (pageCnt == 0) + { + ErasePage(bank, 0); + pageAddress = DEE_PAGE_ADDRESS(bank, 0); + //New page: unavailable, active, reset count + statusWord[0] = 0xF3; + statusWord[0] = statusWord[0] << 16; + statusWord[1] = ERASE_STATE; + DEE_FlashWrite(pageAddress, statusWord, FLASH_UNLOCK_KEY); + continue; + } + //If one active page, do nothing + else if (pageCnt == 1) + { + continue; + } + //If two active pages, erase second and repack first + else if (pageCnt == 2) + { + if ((GetPageStatus(bank, NUM_DATA_EE_PAGES - 1, STATUS_CURRENT) == PAGE_CURRENT) && + (GetPageStatus(bank, 0, STATUS_CURRENT) == PAGE_CURRENT)) + { + currentPage = NUM_DATA_EE_PAGES - 1; + erasePage = 0; + } + else + { + currentPage = 0; + while ((GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT) && + (currentPage < NUM_DATA_EE_PAGES)) + { + currentPage++; + } + erasePage = currentPage + 1; + if (erasePage == NUM_DATA_EE_PAGES) + { + erasePage = 0; + } + } + ErasePage(bank, erasePage); + if (!GetNextAvailCount(bank)) + { + DEE_ActivePartitionPack(bank); + } + continue; + } + else + { + SetPageCorruptStatus(1); + return (DEE_PAGE_CORRUPT); + } + } + return (DEE_NO_ERROR); +} + +static DEE_RETURN_STATUS DEE_ActivePartitionPack(uint8_t bank) +{ + uint16_t currentPage; //Array row (PM page) of active DEE page + uint16_t packedPage; //Array row (PM page) of packed page + uint32_t currentPageAddress; //Current page address + uint32_t packedPageAddress; //Packed page address + uint16_t latchAddr; + uint16_t latchData; + uint8_t dataEEFlags_sh; + uint32_t deeItem[2]; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + + if (currentPage == NUM_DATA_EE_PAGES) + { + SetPagePackBeforeInit(1); + return (DEE_PACK_BEFORE_INIT); // Error - no active page + } + else + { + // Find the next unexpired page to use + packedPage = currentPage + 1; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + while (GetPageStatus(bank, packedPage, STATUS_EXPIRED) == PAGE_EXPIRED) + { + packedPage++; + if (packedPage == NUM_DATA_EE_PAGES) + { + packedPage = 0; + } + if (packedPage == currentPage) + { + SetPageExpiredPage(1); + return (DEE_EXPIRED_PAGE); // Error - all pages expired + } + } + } + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + if (GetNextAvailCount(bank)) + { + SetPagePackBeforePageFull(1); // Pack called before the page was full + } + + dataEEFlags_sh = activePartitionDataEEFlags.val; + SetAddrNotFound(0); // Initialize flag + + + deeItem[0] = ERASE_STATE; + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on dsPIC33E devices with ECC or double word writes + latchAddr = 0; + + do + { + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &latchData); + if (GetAddrNotFound()) //if address is unwritten, skip to next address + { + SetAddrNotFound(0); + } + else + { + deeItem[0] = latchAddr; + deeItem[0] = ((deeItem[0] << 16) | (latchData & 0xFFFF)); + deeItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, deeItem, FLASH_UNLOCK_KEY); + + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + latchAddr++; + } + while (latchAddr != DATA_EE_SIZE); + + activePartitionDataEEFlags.val = dataEEFlags_sh; //Restore status flags + + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage) + 4; // Adjust offset to skip the odd word + + uint32_t data; + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + + while (latchAddr != 0xFF) + { + uint16_t dataRead; + DEE_Read((DATA_EE_SIZE * bank) + latchAddr, &dataRead); + if (dataRead != latchData) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); //Error - data does not match + } + DEE_FlashRead(packedPageAddress, 1, &data); + latchAddr = (data >> 16) &0xFF; + latchData = data & 0xFFFF; + packedPageAddress += 4; // Do not use odd Flash words on devices with ECC or double word writes + } + + //Program page status + currentPageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + packedPageAddress = DEE_PAGE_ADDRESS(bank, packedPage); + + DEE_FlashRead(currentPageAddress, 1, &data); + latchAddr = (data >> 16) & 0xFF; + latchData = data & 0xFFFF; + + if (packedPage == 0) + { + latchData++; //Increment E/W counter + } + + if (latchData >= ERASE_WRITE_CYCLE_MAX - 1) + { + SetPageExpiredPage(1); + latchAddr &= 0xEF; + } + + uint32_t dataItem[2]; + dataItem[0] = latchAddr; + dataItem[0] = (dataItem[0] << 16) | latchData; + dataItem[1] = ERASE_STATE; + DEE_FlashWrite(packedPageAddress, dataItem, FLASH_UNLOCK_KEY); + DEE_FlashRead(packedPageAddress, 1, &data); + uint16_t readAddr = (data >> 16) & 0xFF; + uint16_t readData = data & 0xFFFF; + + if ((latchAddr != readAddr) || + (latchData != readData)) + { + SetPageWriteError(1); + return (DEE_WRITE_ERROR); + } + + //Erase active page + ErasePage(bank, currentPage); + + return (GetPageExpiredPage()); +} + +static uint8_t GetPageStatus(uint8_t bank, uint8_t page, uint8_t field) +{ + uint32_t pageAddress; + uint8_t statusByte; + uint8_t status; + uint32_t statusInfo; + + pageAddress = DEE_PAGE_ADDRESS(bank, page); + DEE_FlashRead(pageAddress, 1, &statusInfo); + statusByte = statusInfo >> 16 & 0xFF; + switch (field) + { + case STATUS_AVAILABLE: + status = ((statusByte & 4) >> 2); + break; + case STATUS_CURRENT: + status = ((statusByte & 8) >> 3); + break; + case STATUS_EXPIRED: + status = ((statusByte & 16) >> 4); + break; + default: + status = 0; + break; + } + return (status); +} + +static void ErasePage(uint8_t bank, uint8_t page) +{ + uint32_t pageAddress = DEE_PAGE_ADDRESS(bank, page); + FLASH_NonBlockingPageErase(pageAddress, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); + return; +} + +static uint16_t GetNextAvailCount(uint8_t bank) +{ + uint16_t nextAvailCount = 0; + uint16_t currentPage; + uint8_t dataEEval; + uint32_t pageAddress; + uint32_t latchAddrData; + + // Find the active page. + for (currentPage = 0; + (currentPage < NUM_DATA_EE_PAGES) && + (GetPageStatus(bank, currentPage, STATUS_CURRENT) == PAGE_NOT_CURRENT); + currentPage++) + { + } + + pageAddress = DEE_PAGE_ADDRESS(bank, currentPage); + + do + { + nextAvailCount += 4; + pageAddress += 4; + DEE_FlashRead(pageAddress, 1, &latchAddrData); + dataEEval = (latchAddrData >> 16) & 0xFF; + } + while ((nextAvailCount < NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) && (dataEEval != 0xFF)); + + if (nextAvailCount == NUMBER_OF_INSTRUCTIONS_IN_PAGE * 2) + { + nextAvailCount = 0; + } + return (nextAvailCount); +} + +static void DEE_FlashWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey) +{ + FLASH_NonBlockingWordWrite(flashAddress, data, unlockKey, FlashProgramOpHandler, NULL); + while(FLASH_OperationStatusGet() == FLASH_OP_BUSY); +} + +static void DEE_FlashRead(flash_adr_t flashAddress, size_t count, flash_data_t *data) +{ + while(FLASH_NonBlockingRead(flashAddress, count, data) == FLASH_OP_BUSY); +} + +bool DEE_ActiveToInactivePartitionDataCopy() +{ + bool dataCopied = false; + uint16_t index = 0; + uint16_t numberOfPagesCopied = 0; + uint32_t dataInActivePartition; + uint32_t dataInInactivePartition; + flash_adr_t srcAddr = DEE_START_ADDRESS_ACTIVE_PARTITION; + flash_adr_t dstAddr = DEE_START_ADDRESS_INACTIVE_PARTITION; + //Check for status word at the start address of each page , if found copy is required + bool copyRequired = DEE_IsDataCopyRequired(); + if (copyRequired) + { + while (numberOfPagesCopied < (DATA_EE_BANKS * NUM_DATA_EE_PAGES)) + { + DEE_FlashRead(srcAddr, 1, &dataInActivePartition); + // Pages with data , copy data to other partition + if (((dataInActivePartition & ERASE_STATE) != ERASE_STATE)) + { + /* Declare arrays for holding the entire page data and packed page data */ + flash_data_t fullPageData[FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS]; + flash_data_t packedPageData[PACKED_PAGE_DATA_SIZE * FLASH_WORD_WRITE_SIZE]; + flash_data_t pageStatus[2]; + /* Initialize the arrays to 0xFFFFFFFF */ + memset(fullPageData, 0xFF, FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS * sizeof(flash_data_t)); + memset(packedPageData, 0xFF, PACKED_PAGE_DATA_SIZE * FLASH_WORD_WRITE_SIZE * sizeof(flash_data_t)); + /* Read entire page and pack the page*/ + DEE_FlashRead(srcAddr, FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS , fullPageData); + DEE_PackedDataGet(fullPageData, FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS, packedPageData); + /*Erase the destination page */ + FLASH_NonBlockingPageErase(dstAddr, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + /*Program the destination page with packed data */ + index = 0; + flash_adr_t tempDestAddr = dstAddr; + while (index < (PACKED_PAGE_DATA_SIZE * FLASH_WORD_WRITE_SIZE)) + { + FLASH_NonBlockingRowWrite(tempDestAddr, &packedPageData[index], FLASH_UNLOCK_KEY, FlashProgramOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + /* Retry write in case of any write error */ + if(FLASH_OperationStatusGet() == FLASH_WRITE_ERROR) + { + DEE_RetryDataWrite(tempDestAddr, &packedPageData[index]); + } + index = index + NUMBER_OF_INSTRUCTIONS_IN_ROW; + tempDestAddr = tempDestAddr + FLASH_WRITE_ROW_SIZE_IN_PC_UNITS; + } + /* copy page status from active partition page to inactive partition page */ + pageStatus[0] = fullPageData[0]; + pageStatus[1] = ERASE_STATE; + DEE_FlashWrite(dstAddr, pageStatus, FLASH_UNLOCK_KEY); + + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + dstAddr = dstAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + dataCopied = true; + } + else + { + /* Check if there is any valid DEE data , this condition occurs when the data copied correctly + during the previous reboot , but there was some issue while erasing the page i.e. some pages are + erased and some are not */ + + DEE_FlashRead(dstAddr, 1, &dataInInactivePartition); + if ((dataInInactivePartition & ERASE_STATE) == ERASE_STATE) + { + FLASH_NonBlockingPageErase(dstAddr, FLASH_UNLOCK_KEY, FlashEraseOpHandler , NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + } + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + dstAddr = dstAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + } + numberOfPagesCopied++; + } + /* Delete data from the active partition */ + if (dataCopied) { + srcAddr = DEE_START_ADDRESS_ACTIVE_PARTITION; + for (index = 0; index < numberOfPagesCopied; index++) { + FLASH_NonBlockingPageErase(srcAddr, FLASH_UNLOCK_KEY, FlashEraseOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + } + } + + } + return dataCopied; +} + +bool DEE_IsDataCopyRequired() +{ + bool copyRequired = false; + uint16_t numberOfPagesChecked = 0; + uint32_t dataInActivePartition; + flash_adr_t srcAddr = DEE_START_ADDRESS_ACTIVE_PARTITION; + while (numberOfPagesChecked < (DATA_EE_BANKS * NUM_DATA_EE_PAGES)) + { + /* Check whether data is present at address immediately after the page status */ + DEE_FlashRead(srcAddr + 4, 1, &dataInActivePartition); + if ((dataInActivePartition & ERASE_STATE) != ERASE_STATE) + { + copyRequired = true; + break; + } + srcAddr = srcAddr + FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS; + numberOfPagesChecked++; + } + return copyRequired; +} + +static void DEE_PackedDataGet(flash_data_t *fullPageData, uint32_t fullPageDataSize, flash_data_t *packedPageData) +{ + uint8_t deeAddress = MAX_DATA_SIZE_PER_PAGE; + uint32_t exists[MAX_DATA_SIZE_PER_PAGE] = {0}; + uint32_t packedDataIndex = FLASH_WORD_WRITE_SIZE; + for(int32_t index = fullPageDataSize - 1; index >= FLASH_WORD_WRITE_SIZE; index--) + { + deeAddress = (fullPageData[index] & DEE_ADDRESS_MASK) >> 16; + if(!exists[deeAddress] && deeAddress != MAX_DATA_SIZE_PER_PAGE) + { + packedPageData[packedDataIndex] = fullPageData[index]; + packedDataIndex = packedDataIndex + FLASH_WORD_WRITE_SIZE; + exists[deeAddress] = 1; + } + } +} + +static void DEE_RetryDataWrite(flash_adr_t destAddr, flash_data_t *packedPageData) { + uint16_t retryIndex = 0; + for (retryIndex = 0; retryIndex < WRITE_RETRY_COUNT; retryIndex++) { + FLASH_NonBlockingRowWrite(destAddr, packedPageData, FLASH_UNLOCK_KEY, FlashProgramOpHandler, NULL); + while (FLASH_OperationStatusGet() == FLASH_OP_BUSY); + if (FLASH_OperationStatusGet() != FLASH_WRITE_ERROR) { + break; + } + } +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_hardware_nonblocking.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_hardware_nonblocking.h new file mode 100644 index 0000000..43f16c4 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_hardware_nonblocking.h @@ -0,0 +1,203 @@ + +/** + * FLASH Generated Driver Header File + * + * @file flash.h + * + * @ingroup Flash Driver + * + * @brief This is the generated driver header file for the FLASH driver + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_NONBLOCKING_HARDWARE_H +#define FLASH_NONBLOCKING_HARDWARE_H + +#include +#include +#include +#include "flash_types.h" +/** + @ingroup flashdriver + @brief Defines FLASH Flash PC unit size +*/ +#define FLASH_PC_UNIT_SIZE 2U +/** + @ingroup flashdriver + @brief Defines FLASH unlock key value +*/ +#define FLASH_UNLOCK_KEY 0x00AA0055 +/** + @ingroup flashdriver + @brief Defines FLASH write row size in instruction counts +*/ +#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U +/** + @ingroup flashdriver + @brief Defines FLASH write row size in PC counts +*/ +#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE) +/** + @ingroup flashdriver + @brief Defines FLASH erase page size in instruction counts +*/ +#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U +/** + @ingroup flashdriver + @brief Defines FLASH erase page size in PC counts +*/ +#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE) +/** + @ingroup flashdriver + @brief Defines if FLASH has ECC +*/ +#define FLASH_HAS_ECC 1 +/** + @ingroup flashdriver + @brief Defines FLASH erase page mask value +*/ +#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U)) +/** + @ingroup flashdriver + @brief Defines FLASH odd address mask value +*/ +#define FLASH_ODD_ADDRESS_MASK 1U +/** + @ingroup flashdriver + @brief Defines FLASH error mask value +*/ +#define FLASH_ERROR_MASK 0x2100 + + +/** + * @ingroup flashdriver + * @brief This routine erases a page indicated by the page aligned address. + * @param[in] address - Flash page aligned address. + * @return bool - Returns True if operation successful else returns false. + */ +bool FLASH_NonBlockingErasePage(flash_adr_t address, flash_key_t unlockKey); + + +/** + * @ingroup flashdriver + * @brief This routine erases a page indicated by the page aligned address. + * @param[in] panel - Panel to erase. + * @return bool - Returns True if operation successful else returns false. + */ +bool FLASH_NonBlockingEraseBulk(uint32_t panel, flash_key_t unlockKey); + +/* The address in the Read and Write word functions below must be even */ + +/** + * @ingroup flashdriver + * @brief This routine writes two 24 bit instructions to the indicated address in flash. + * @param[in] address - Flash address. + * @param[in] data1 - First 24 bit data to be written(First word). + * @param[in] data2 - Second 24 bit data to be written(Second word). + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteDoubleWord24(flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey); + + +/** + * @ingroup flashdriver + * @brief This routine writes two ,16 bit instructions to the indicated address in flash. + * @param[in] address - Flash address. + * @param[in] data1 - First 16 bit data to be written(First word). + * @param[in] data2 - Second 16 bit data to be written(Second word). + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteDoubleWord16(flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey); + + +/* Program the flash one row at a time. */ + + +/** + * @ingroup flashdriver + * @brief + * This routine writes a single row of data from the location given in *data to the flash location in address. + * Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in + * *data must be row aligned. + * @param[in] address - Flash address. + * @param[in] *data - Address of the data to be written. + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteRow24(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey); + + +/** + * @ingroup flashdriver + * @brief + * This routine writes a single row of data from the location given in *data to the flash location in address. + * Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the + * flash is not programmed.The address in *data must be row aligned. + * @param[in] address - Flash address. + * @param[in] *data - Address of the data to be written. + * @return bool - Returns true if operation is successful else returns false. + */ +bool FLASH_NonBlockingWriteRow16(flash_adr_t address, uint16_t *data, flash_key_t unlockKey); + +/* The address in the Read and Write word functions below must be even */ + +/** + * @ingroup flashdriver + * @brief This routine reads a 24 bit instruction from the indicated address in flash. + * @param[in] address - Flash address. + * @return uint32_t - 24 bit data. + */ +uint32_t FLASH_NonBlockingReadWord24(flash_adr_t address); + + +/** + * @ingroup flashdriver + * @brief This routine reads a 16 bit instruction from the indicated address in flash. + * @param[in] address - Flash address. + * @return uint16_t - 16 bit data. + */ +uint16_t FLASH_NonBlockingReadWord16(flash_adr_t address); + +/** + * @ingroup flashdriver + * @brief This routiner returns the page offset the given flash address. + * @param[in] address - Flash address. + * @return uint32_t - returns offset. + */ +uint16_t FLASH_ErasePageOffsetGet(flash_adr_t address); + + +/** + * @ingroup flashdriver + * @brief This routine returns the page aligned address for a given flash address.. + * @param[in] address - Flash address. + * @return uint32_t - Returns page aligned flash address. + */ +uint32_t FLASH_ErasePageAddressGet(flash_adr_t address); + +#endif /* FLASH_NONBLOCKING_HARDWARE_H */ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_interface.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_interface.h new file mode 100644 index 0000000..a380b44 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_interface.h @@ -0,0 +1,110 @@ + +/** + * flash Generated Driver Interface Header File + * + * @file flash_interface.h + * + * @defgroup Flash Driver + * + * @brief FLASH Driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_INTERFACE_H +#define FLASH_INTERFACE_H + +// Section: Included Files +#include +#include +#include +#include "flash_types.h" + +// Section: Data Type Definitions + + +/** + @ingroup flashdriver + @struct FLASH_INTERFACE + @brief Structure containing the function pointers of FLASH driver. +*/ +struct FLASH_INTERFACE +{ + enum FLASH_RETURN_STATUS (*PageErase)(flash_adr_t address, flash_key_t unlockKey); + ///< Pointer to FLASH_PageErase e.g. \ref FLASH_PageErase + + enum FLASH_RETURN_STATUS (*Write)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_WordWrite e.g. \ref FLASH_WordWrite + + enum FLASH_RETURN_STATUS (*RowWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_RowWrite e.g. \ref FLASH_RowWrite + + enum FLASH_RETURN_STATUS (*Read)(flash_adr_t address, size_t count, uint32_t *data); + ///< Pointer to FLASH_Read e.g. \ref FLASH_Read + + uint32_t (*PageAddressGet)(flash_adr_t address); + ///< Pointer to FLASH_ErasePageAddressGet e.g. \ref FLASH_ErasePageAddressGet + + uint16_t (*PageOffsetGet)(flash_adr_t address); + ///< Pointer to FLASH_ErasePageOffsetGet e.g. \ref FLASH_ErasePageOffsetGet + + enum FLASH_RETURN_STATUS (*OperationStatusGet)(void); + ///< Pointer to FLASH_OperationStatusGet e.g. \ref FLASH_OperationStatusGet + + enum FLASH_RETURN_STATUS (*NonBlockingPageErase)(flash_adr_t address, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingPageErase e.g. \ref FLASH_NonBlockingPageErase + + enum FLASH_RETURN_STATUS (*NonBlockingBulkErase)(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingBulkErase e.g. \ref FLASH_NonBlockingBulkErase + + enum FLASH_RETURN_STATUS (*NonBlockingWordWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingWordWrite e.g. \ref FLASH_NonBlockingWordWrite + + enum FLASH_RETURN_STATUS (*NonBlockingRowWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + ///< Pointer to FLASH_NonBlockingRowWrite e.g. \ref FLASH_NonBlockingRowWrite + + enum FLASH_RETURN_STATUS (*NonBlockingRead)(flash_adr_t address, size_t count, uint32_t *data); + ///< Pointer to FLASH_NonBlockingRead e.g. \ref FLASH_NonBlockingRead + + enum FLASH_RETURN_STATUS (*NonBlockingPolledPageErase)(flash_adr_t address, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledPageErase e.g. \ref FLASH_NonBlockingPolledPageErase + + enum FLASH_RETURN_STATUS (*NonBlockingPolledBulkErase)(enum FLASH_PANEL panel, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledBulkErase e.g. \ref FLASH_NonBlockingPolledBulkErase + + enum FLASH_RETURN_STATUS (*NonBlockingPolledWordWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledWordWrite e.g. \ref FLASH_NonBlockingPolledWordWrite + + enum FLASH_RETURN_STATUS (*NonBlockingPolledRowWrite)(flash_adr_t address, flash_data_t* data, flash_key_t unlockKey); + ///< Pointer to FLASH_NonBlockingPolledRowWrite e.g. \ref FLASH_NonBlockingPolledRowWrite + + enum FLASH_RETURN_STATUS (*NonBlockingPolledRead)(flash_adr_t address, size_t count, uint32_t *data); + ///< Pointer to FLASH_NonBlockingPolledRead e.g. \ref FLASH_NonBlockingPolledRead +}; + +#endif //FLASH_INTERFACE_H diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_nonblocking.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_nonblocking.h new file mode 100644 index 0000000..eefb0ff --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_nonblocking.h @@ -0,0 +1,144 @@ + +/** + * FLASH Generated Driver Header File + * + * @file flash.h + * + * @ingroup Flash Driver + * + * @brief FLASH driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_NONBLOCKING_H +#define FLASH_NONBLOCKING_H + +#include +#include +#include +#include "xc.h" +#include "flash_interface.h" +#include "flash_hardware_nonblocking.h" + +#include "flash_interface.h" + +// Section: Data Type Definitions + +/** + @ingroup flashdriver + @brief Structure object of type FLASH_INTERFACE assigned with name + displayed in the Melody Driver User interface. A structure pointer can be used to achieve portability + across the FLASH having same interface structure. +*/ + +extern const struct FLASH_INTERFACE flash; + +// Section: Data Type Definitions + +/** + * @ingroup flashdriver + * @brief This function initializes the nvm controller. + * @return void + */ +void FLASH_Initialize(); + +/** + * @ingroup flashdriver + * @brief This function gets the status of nvm controller. + * @return returns the status of the previous operation. + */ +enum FLASH_RETURN_STATUS FLASH_OperationStatusGet(); + +/** + * @ingroup flashdriver + * @brief This function erases a page. + * @param[in] flashAddress : Flash address + * @param[in] unlockKey : Flash unlock key + * @param[in] callbackHandler : Pointer to call back handler + * @param[in] context : Optional pointer to context to handle user contexts + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase(flash_adr_t flashAddress, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + +/** + * @ingroup flashdriver + * @brief This function erases a panel. + * @param[in] panel : Flash panel to erase + * @param[in] unlockKey : Flash unlock key + * @return * @return returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + + +/** + * @ingroup flashdriver + * @brief This function writes the specified data to the specified address. + * @param[in] flashAddress : Flash address + * @param[in] data : Pointer of the data to be written. + * @param[in] unlockKey : Flash unlock Key. + * @param[in] callbackHandler : pointer to call back handler + * @param[in] context : Optional pointer to context to handle user contexts + * This will write the TWO WORDS pointed to by the pointer. + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingWordWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context); + +/** + * @ingroup flashdriver + * @brief This function writes the specified data to the specified address. + * @param[in] flashAddress : Flash address + * @param[in] data : Pointer of the data to be written + * @param[in] unlockKey : Flash unlock Key. + * @param[in] callbackHandler : Pointer to call back handler + * @param[in] context : Optional pointer to context to handle user contexts + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_CALLBACK_HANDLER, FLASH_WRITE_ERROR + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingRowWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callback, void* context); + +/** + * @ingroup flashdriver + * @brief This function reads the data from the specified address. + * @param[in] flashAddress : Flash address of + * @param[out] data : Pointer to read the data + * @return FLASH_RETURN_STATUS: returns FLASH_NO_ERROR if operation is successful, if the operation is in progress then it returns FLASH_OP_IN_PROGRESS, + * if there is a previous operation in progress then it returns FLASH_OP_BUSY , in case of any unsuccessful operation it returns errors like + * FLASH_INVALID_ADDRESS, FLASH_INVALID_DATA + */ +enum FLASH_RETURN_STATUS FLASH_NonBlockingRead(flash_adr_t flashAddress, size_t count, flash_data_t *data); + + +#endif /* FLASH_NONBLOCKING_H */ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_types.h new file mode 100644 index 0000000..1224f6c --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/flash_types.h @@ -0,0 +1,77 @@ + +/** + * flash Generated Driver Types Header File + * + * @file flash_types.h + * + * @ingroup Flash Driver + * + * @brief FLASH Driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef FLASH_TYPES_H +#define FLASH_TYPES_H + +typedef void (*FLASH_CALLBACK)(void *); + +typedef uint32_t flash_adr_t; +typedef uint32_t flash_data_t; +typedef uint32_t flash_key_t; + +/** + @ingroup flashdriver + @enum FLASH_PANEL + @brief This enum is be used for the flash panel numbers and maximum flash panels. +*/ +enum FLASH_PANEL +{ + FLASH_PANEL_1 = 0, + FLASH_PANEL_2 = 1, + FLASH_PANEL_MAX_PANELS +}; + +/** + @ingroup flashdriver + @enum FLASH_RETURN_STATUS + @brief This enum is be used to return the status of write, read and erase operation. +*/ +enum FLASH_RETURN_STATUS { + FLASH_NO_ERROR, /**< No error occurred */ + FLASH_INVALID_ADDRESS, /**< Invalid address */ + FLASH_INVALID_DATA, /**< Invalid data */ + FLASH_WRITE_ERROR, /**< Write error has occurred */ + FLASH_READ_ERROR, /**< Read error has occurred */ + FLASH_ERASE_ERROR, /**< Flash erase error occurred */ + FLASH_INVALID_CALLBACK_HANDLER, /**< Invalid parameter to operation */ + FLASH_OP_BUSY, /**< Flash is physically busy */ + FLASH_OP_IN_PROGRESS /**< Flash operation is in progress */ +}; + +#endif //FLASH_TYPES_H diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/src/flash_asm_nonblocking.s b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/src/flash_asm_nonblocking.s new file mode 100644 index 0000000..056760a --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/src/flash_asm_nonblocking.s @@ -0,0 +1,721 @@ +;/******************************************************************************* +; flash.s for PIC24 and dsPIC33 Cores +; +; Summary: +; Assembly language optimized helper routines required flash functions +; +; Description: +; Assembly language optimized for flash access +; +;*******************************************************************************/ +; +;// DOM-IGNORE-BEGIN +;/******************************************************************************* +; Copyright (C) 2016 Microchip Technology Inc. +; +; MICROCHIP SOFTWARE NOTICE AND DISCLAIMER: You may use this software, and any +; derivatives created by any person or entity by or on your behalf, exclusively +; with Microchip's products. Microchip and its licensors retain all ownership +; and intellectual property rights in the accompanying software and in all +; derivatives here to. +; +; This software and any accompanying information is for suggestion only. It +; does not modify Microchip's standard warranty for its products. You agree +; that you are solely responsible for testing the software and determining its +; suitability. Microchip has no obligation to modify, test, certify, or +; support the software. +; +; THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER +; EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED +; WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR +; PURPOSE APPLY TO THIS SOFTWARE, ITS INTERACTION WITH MICROCHIP'S PRODUCTS, +; COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. +; +; IN NO EVENT, WILL MICROCHIP BE LIABLE, WHETHER IN CONTRACT, WARRANTY, TORT +; (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY), STRICT LIABILITY, +; INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, SPECIAL, PUNITIVE, +; EXEMPLARY, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, FOR COST OR EXPENSE OF +; ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWSOEVER CAUSED, EVEN IF +; MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. +; TO THE FULLEST EXTENT ALLOWABLE BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL +; CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF +; FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. +; +; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE +; TERMS. +;*******************************************************************************/ + .equ WRITE_DWORD_CODE, 0x4001 + .equ ERASE_PAGE_CODE, 0x4003 + .equ ACTIVE_BULK_ERASE_CODE, 0x400E + .equ INACTIVE_BULK_ERASE_CODE, 0x4004 + .equ FLASH_WRITE_ROW_CODE, 0x4002 + .equ ERASE_WRITE_OP_MASK, 0x520F + .equ FLASH_ERASE_WRITE_OP_MASK, 0x520F + .equ FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS, 128 + .equ FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS, 1024 + .equ FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS, 1024 * 2 + .equ FLASH_ERASE_PAGE_MASK, (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1)) + .data + _FlashKey: .long 0xFFFFFFFF + .text + .pushsection .NVM_NonBlockingFlash, code + + +/** + * ;void FLASH_NonBlockingUnlock(uint32_t key); + * Used to program the flash key in memory variable located in RAM + * the valid key is 0x00AA0055 + * + * + * @param key 32-bit (unsigned long) for the key + * + * Registers used: w0 w1 + * + * Inputs: + * w0,w1 = long data - Flash Key to save (32 bits) + * + */ + + .global _FLASH_NonBlockingUnlock + .type _FLASH_NonBlockingUnlock, @function + reset + _FLASH_NonBlockingUnlock: + mov #_FlashKey, W2 + mov W0, [W2++] + mov W1, [W2] + return; + +/** + * ;void FLASH_NonBlockingLock(); + * Locks the flash from programming by resetting the NVMKEY in memory + * + * + * @param key 32-bit (unsigned long) for the key + * + * Registers used: w0 w1 + * + * Inputs: + * w0,w1 = long data - Flash Key to save (32 bits) + * + */ + + .global _FLASH_NonBlockingLock + .type _FLASH_NonBlockingLock, @function + .extern NVMKEY + + reset + _FLASH_NonBlockingLock: + clr W0 + clr W1 + rcall _FLASH_NonBlockingUnlock + clr NVMKEY + return; + + /** + * ;void FLASH_NonBlockingSendNvmKey(uint32_t key); + * Procedure to take the NVM key from memory and program the flash controller + * with it. A valid key is 0x00AA0055 + * + * + * @param key 32-bit (unsigned long) key + * + * Registers used: w0 w1 (Preserved) + * + * Inputs: + * w0,w1 = long data - Flash Key to use (32 bits) + */ + reset + .global _FLASH_NonBlockingSendNvmKey + .type _FLASH_NonBlockingSendNvmKey, @function + .extern NVMKEY + .extern TBLPAG + + reset +_FLASH_NonBlockingSendNvmKey: + push W0 + push W1 + + mov #_FlashKey, w1 + + ; Disable interrupts + push INTCON2 ; Save Global Interrupt Enable bit. + bclr INTCON2, #15 ; Disable interrupts + + ; Write the KEY sequence + mov [W1++], W0 + mov W0, NVMKEY + mov [W1], W0 + mov W0, NVMKEY + bset NVMCON, #15 + + ; Insert two NOPs after programming + nop + nop + ; Restore interrupts to original value. + pop INTCON2 + + pop W1 + pop W0 + return + + +/** + * ;uint32_t FLASH_NonBlockingReadWord24(uint32_t flashAddress); + * Reads the 24 bit instruction located at the address passed to this function. + * + * + * @param flashAddress 24-bit (unsigned long) specifying a target address + * that needs to be read. Needs to be aligned to an even + * address. + * + * Registers used: w0 w1 w2 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to read (24 bits) + * + * outputs: + * w0,w1 = 32 bit data contains the flash data read. + **/ + + reset + .global _FLASH_NonBlockingReadWord24 + .type _FLASH_NonBlockingReadWord24, @function + .extern TBLPAG + + + _FLASH_NonBlockingReadWord24: + mov TBLPAG, W2 + mov W1, TBLPAG ; Little endian, w1 has MSW, w0 has LSX + tblrdh [W0], W1 ; read MSW of data to high latch + tblrdl [W0], W0 ; read LSW of data + mov W2, TBLPAG ; Restore register, + return + +/** + * ;uint16_t FLASH_NonBlockingReadWord16(uint32_t flashAddress); + * Reads the 16 bit instruction located at the address passed to this function. + * Address must be aligned to an even address. + * + * + * @param flashAddress 24-bit (unsigned long) specifying a target address + * that needs to be read. Needs to be aligned to an even + * address. + * + * Registers used: w0 w1 w2 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to read (24 bits) + * + * outputs: + * w0 = 16 bit data contains the flash data read. + * + **/ + + reset + .global _FLASH_NonBlockingReadWord16 + .type _FLASH_NonBlockingReadWord16, @function + .extern TBLPAG + + + _FLASH_NonBlockingReadWord16: + mov TBLPAG, W2 + mov W1, TBLPAG ; Little endian, w1 has MSW, w0 has LSX + tblrdl [W0], W0 ; read LSW of data + mov W2, TBLPAG ; restore register + return + + +/** + * void FLASH_NonBlockingErasePage(unsigned long flashAddress); + * Erases the page containing the specified address. Be very careful if calling + * this function as the function will erase any legal page, + * + * NOTE: This function can take upwards of 45ms on some device families and + * target pages to complete. At frequencies appreciably slower than the maximum + * device frequency, even longer may be required. Therefore, you may need to + * issue a ClrWdt() call before calling this function, assuming the Watchdog + * timer is enabled. This also means that you should not configure a watchdog + * timeout of less than ~64ms, even when you pre-clear the timeout. This + * function does NOT internally clear the watchdog for you as it is packaged as + * a library routine where not everyone would desire such behavior. + * + * @param flashAddress 24-bit (unsigned long) specifying the first address on the page + * to be erased. Must be page aligned. + * + * Registers used: w0 w1 w2 w3 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to erase (24 bits) + * w2,w3 = long data - NVM Unlock Key + * + * outputs: + * 0 - Fail + * 1 - Pass + * + **/ + + .global _FLASH_NonBlockingErasePage + .type _FLASH_NonBlockingErasePage, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + reset + + + +_FLASH_NonBlockingErasePage: + push w0 + push w1 + push w2 + mov w2 , w0 + mov w3 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + mov #FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS-1, w2 ; get mask and validate all lower bits = 0 + and w2, w0, w2 + bra NZ,3f + + mov #ERASE_PAGE_CODE, w2 + mov w2, NVMCON + mov w0, NVMADR + mov w1, NVMADRU ; MSB + + call _FLASH_NonBlockingSendNvmKey + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + +/** + * void FLASH_NonBlockingEraseBulk(unsigned char inactive); + * Erases the partition. Be very careful if calling + * this function as the function will erase the partition! + * + * NOTE: This function can take upwards of 45ms on some device families and + * target pages to complete. At frequencies appreciably slower than the maximum + * device frequency, even longer may be required. Therefore, you may need to + * issue a ClrWdt() call before calling this function, assuming the Watchdog + * timer is enabled. This also means that you should not configure a watchdog + * timeout of less than ~64ms, even when you pre-clear the timeout. This + * function does NOT internally clear the watchdog for you as it is packaged as + * a library routine where not everyone would desire such behavior. + * + * @param partition (unsigned char) if 0, indicates the single partition (for single + * partition devices) or active partition (for dual partition devices). + * if 1, indicates the inactive partition (for dual partition devices only). + * + * Registers used: w0 w1 w2 w3 + * TBLPAG Preserved + * + * Inputs: + * w0 = char data - indicates active/inactive partition + * w1,w2 = long data - NVM Unlock Key + * + * outputs: + * 0 - Fail + * 1 - Pass + * + **/ + .global _FLASH_NonBlockingEraseBulk + .type _FLASH_NonBlockingEraseBulk, @function + .extern TBLPAG + .extern NVMCON + reset + +_FLASH_NonBlockingEraseBulk: + push w0 + push w1 + push w2 + push w3 + mov w2 , w0 + mov w3 , w1 + call _FLASH_NonBlockingUnlock + pop w3 + pop w2 + pop w1 + pop w0 + + mov #ACTIVE_BULK_ERASE_CODE, w2 ; default to active/single partition + mov #0, w3 + cpseq w3, w0 ; if w0 == 0, skip the next instruction + mov #INACTIVE_BULK_ERASE_CODE, w2 ; load the inactive partition bulk-erase code + + mov w2, NVMCON + mov w0, NVMADR + mov w1, NVMADRU ; MSB + + call _FLASH_NonBlockingSendNvmKey + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + /** + * ;void FLASH_NonBlockingWriteDoubleWord24(uint32_t flashAddress, uint32_t instructionData0, uint32_t instructionData1); + * Writes two 24-bit instruction to the flash at the flashAdddress + * Only the lower 24 bits of each instruction will be written since the flash + * is only 24 bits wide and all data in the upper 8 bits will be lost. + * + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param uint32_t instructionData0 24 bit instruction to be written first. + * @param uint32_t instructionData1 24 bit instruction to be written second. + * + * + * Registers used: w0 w1 w2 w3 w4 w5 w6 w7 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2,w3 = long data - 24 bits of data to write to flash (24 bits) + * w4,w5 = long data - 24 bits of data to write to flash (24 bits) + * w6,w7 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteDoubleWord24 + .type _FLASH_NonBlockingWriteDoubleWord24, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + reset + +_FLASH_NonBlockingWriteDoubleWord24: + push w0 + push w1 + push w2 + mov w6 , w0 + mov w7 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + + btsc w0, #0 ; Check for a valid address Bit 0 and Bit 1 clear + bra 3f + btsc w0, #1 + bra 3f + +good24: + mov W1,NVMADRU + mov W0,NVMADR + + mov #WRITE_DWORD_CODE, W0 + mov W0, NVMCON + + mov TBLPAG, W0 ; save it + mov #0xFA,W1 + mov W1,TBLPAG + mov #0,W1 + + ; Perform the TBLWT instructions to write the latches + tblwtl W2,[W1] + tblwth W3,[W1++] + tblwtl W4,[W1] + tblwth w5,[W1++] + + call _FLASH_NonBlockingSendNvmKey + + + mov W0, TBLPAG + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + + /** + * ;void FLASH_NonBlockingWriteDoubleWord16(uint32_t flashAddress, uint16_t Data0, uint16_t Data1, uint32_t unlockKey); + * Writes two 16-bit words to the flash at the flashAdddress + * The upper 8 bits of the 24 bit flash entry will have its data programmed as + * 0xFF. + * + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param uint16_t Data0 16 bit word to be written first. + * @param uint16_t Data1 16 bit word to be written second. + * + * Registers used: w0 w1 w2 w3 w4 w5 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2 = 16 bit data - 16 bits of data to write to flash + * w3 = 16 bit data - 16 bits of data to write to flash + * w4,w5 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteDoubleWord16 + .type _FLASH_NonBlockingWriteDoubleWord16, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + reset + + _FLASH_NonBlockingWriteDoubleWord16: + push w0 + push w1 + push w2 + mov w4 , w0 + mov w5 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + + btsc w0, #0 ; Check for a valid address Bit 0 and Bit 1 clear + bra 3f + btsc w0, #1 + bra 3f + +good16: + mov W1,NVMADRU + mov W0,NVMADR + + mov TBLPAG, W1 ; save it + + mov #WRITE_DWORD_CODE, W0 + mov W0, NVMCON + + mov #0xFA,W0 + mov W0,TBLPAG + mov #0,W0 + + tblwtl W2,[W0] ; Perform the TBLWT instructions to write the latches + mov #0xFF,W2 + tblwth W2,[W0++] + tblwtl W3,[W0] + tblwth W2,[W0++] + + call _FLASH_NonBlockingSendNvmKey + + + mov w1, TBLPAG + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + + +/** + * ;void FLASH_NonBlockingWriteRow24(uint32_t flashAddress, uint32_t *data, uint32_t unlockKey); + * Writes a single Row to the address flashAddress from the address of data + * Since this is passed as a 32 bit value + * and flash is only 24 bit wide, all data in the upper 8 bits will be lost. + * + * This method uses the built in row load and program from a RAM buffer. + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param *data 16 bit value of the SRAM address to read the data from. + * + * Registers used: w0 w1 w2 w3 w4 w5 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2,w3 = long data - 24 bits of data address to write to flash (24 bits) + * w4,w5 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteRow24 + .type _FLASH_NonBlockingWriteRow24, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + .extern NVMSRCADRL + reset + + _FLASH_NonBlockingWriteRow24: + push w0 + push w1 + push w2 + push w3 + mov w4 , w0 + mov w5 , w1 + call _FLASH_NonBlockingUnlock + pop w3 + pop w2 + pop w1 + pop w0 + + mov #((FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS*2)-1), w3 ; get mask and validate all lower bits = 0 + and w3, w0, w3 + bra NZ,3f + + + mov W0,NVMADR + mov W1,NVMADRU + + mov #FLASH_WRITE_ROW_CODE, W0 ; RPDF = 0 so not compressed + mov W0, NVMCON + + mov W2, NVMSRCADRL + + call _FLASH_NonBlockingSendNvmKey + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + + + + +/** + * ;void FLASH_NonBlockingWriteRow16(uint32_t flashAddress, uint16_t sourceRamAddress, uint32_t unlockKey); + * Writes a single Row to the address flashAddress from the sourceAddress + * Since this is passed as a 32 bit value + * and flash is only 24 bit wide, all data in the upper 8 bits will be lost. + * + * This method uses the built in row load and program from a RAM buffer. + * + * @param flashAddress 32 bit value specifying a target address in flash + * that this firmware will write to. It needs to be on a + * addresses divisible by 4. + * + * @param sourceAddress 16 bit value of the address to read the data from. + * + * Registers used: w0 w1 w2 + * TBLPAG Preserved + * + * Inputs: + * w0,w1 = long data - Address in flash to write (24 bits) + * w2 = 16 bit - 16 bits of data address to write to flash (16 bits) + * w4,w5 = long data - NVM Unlock Key + * + * outputs: + * none + * + **/ + + .global _FLASH_NonBlockingWriteRow16 + .type _FLASH_NonBlockingWriteRow16, @function + .extern TBLPAG + .extern NVMCON + .extern NVMADRU + .extern NVMADR + .extern NVMSRCADRL + reset + + _FLASH_NonBlockingWriteRow16: + push w0 + push w1 + push w2 + mov w4 , w0 + mov w5 , w1 + call _FLASH_NonBlockingUnlock + pop w2 + pop w1 + pop w0 + + mov #((FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS*2)-1), w3 ; get mask and validate all lower bits = 0 + and w3, w0, w3 + bra NZ,3f + + + mov W0,NVMADR + mov W1,NVMADRU + + mov #WRITE_DWORD_CODE, W0 + mov W0, NVMCON + + mov #0xFA,W0 + mov W0,TBLPAG + mov #0,W0 + + mov #FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS, W1 + mov #0xFF, W4 +1: + tblwtl [w2++], [W0] ; Perform the TBLWT instructions to write the latches + tblwth W4, [W0++] + tblwtl [w2++], [W0] ; Perform the TBLWT instructions to write the latches + tblwth W4, [W0--] + + call _FLASH_NonBlockingSendNvmKey + +prog_wait: + btsc NVMCON, #15 + bra prog_wait + + + inc2 NVMADR + inc2 NVMADR + sub #2, W1 + bra NZ, 1b + + call _FLASH_NonBlockingLock + mov #1, w0 ; default return true + btsc NVMCON, #13 ; if error bit set, +3: mov #0, w0 ; return false + return; + + +;uint16_t FLASH_ErasePageOffsetGet(uint32_t flashAddress) + .global _FLASH_ErasePageOffsetGet + .type _FLASH_ErasePageOffsetGet, @function + +_FLASH_ErasePageOffsetGet: + mov #((~FLASH_ERASE_PAGE_MASK) & 0xFFFF), W2 + and w2, w0, w0 + return + +;uint32_t FLASH_ErasePageAddressGet(uint32_t flashAddress); + + .global _FLASH_ErasePageAddressGet + .type _FLASH_ErasePageAddressGet, @function + +_FLASH_ErasePageAddressGet: + + mov #(FLASH_ERASE_PAGE_MASK & 0xFFFF) , W2 ;LSW + and w2, w0, w0 + mov #((FLASH_ERASE_PAGE_MASK >> 16) & 0xFFFF), W2 ; MSW + and w2, w1, w1 + + return + + + .popsection diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/src/flash_nonblocking.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/src/flash_nonblocking.c new file mode 100644 index 0000000..c34dc96 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/flash/src/flash_nonblocking.c @@ -0,0 +1,277 @@ +/** + * FLASH Generated Driver Source File + * + * @file flash.c + * + * @ingroup Flash Driver + * + * @brief This is the generated driver source file for FLASH driver + * + * @skipline @version Firmware Driver Version 1.1.0 + * + * @skipline @version PLIB Version 3.2.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include "../flash_nonblocking.h" + +// User callback and context handles. +static void (*userCallbackHandler)(void *) = NULL; +static void *userContext = NULL; +bool lock = false; + + +// Section: Driver Interface +const struct FLASH_INTERFACE flash = { + .PageAddressGet = FLASH_ErasePageAddressGet, + .PageOffsetGet = FLASH_ErasePageOffsetGet, + .NonBlockingPageErase = FLASH_NonBlockingPageErase, + .NonBlockingBulkErase = FLASH_NonBlockingBulkErase, + .NonBlockingRead = FLASH_NonBlockingRead, + .NonBlockingWordWrite = FLASH_NonBlockingWordWrite, + .NonBlockingRowWrite = FLASH_NonBlockingRowWrite, + .NonBlockingPolledPageErase = NULL, + .NonBlockingPolledBulkErase = NULL, + .NonBlockingPolledRead = NULL, + .NonBlockingPolledWordWrite = NULL, + .NonBlockingPolledRowWrite = NULL, + .OperationStatusGet = FLASH_OperationStatusGet + +}; + +void FLASH_Initialize(void) +{ + // Flash Interrupt + IFS0bits.NVMIF = 0U; + IEC0bits.NVMIE = 1U; +} + +void __attribute__ ( ( interrupt, no_auto_psv ) ) _NVMInterrupt(void) +{ + IFS0bits.NVMIF = 0U; + + //Interrupt means operation completion, release the lock + lock = false; + + if (NULL != userCallbackHandler) { + (*userCallbackHandler)(userContext); + } +} + + +enum FLASH_RETURN_STATUS FLASH_OperationStatusGet() +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_NO_ERROR; + if(NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + if(NVMCON & FLASH_ERROR_MASK) + { + flashReturnStatus = FLASH_WRITE_ERROR; + } + lock = false; + } + return flashReturnStatus; +} + + +enum FLASH_RETURN_STATUS FLASH_NonBlockingPageErase(uint32_t flashAddress, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if (0U != ((uint16_t)flashAddress & ~FLASH_ERASE_PAGE_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingErasePage(flashAddress, unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + + +enum FLASH_RETURN_STATUS FLASH_NonBlockingBulkErase(enum FLASH_PANEL panel, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if ((panel < 0) || (panel >= FLASH_PANEL_MAX_PANELS)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingEraseBulk(panel, unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + +enum FLASH_RETURN_STATUS FLASH_NonBlockingWordWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if (NULL == data) + { + flashReturnStatus = FLASH_INVALID_DATA; + } + else if (0U != ((uint16_t)flashAddress & FLASH_ODD_ADDRESS_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + // Save the handler and context to call for completion of this operation. + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingWriteDoubleWord24(flashAddress, *data, *(data+1), unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + +enum FLASH_RETURN_STATUS FLASH_NonBlockingRowWrite(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey, FLASH_CALLBACK callbackHandler, void* context) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_IN_PROGRESS; + if(false == lock) + { + if (NULL == data) + { + flashReturnStatus = FLASH_INVALID_DATA; + } + else if (0U != ((uint16_t)flashAddress & FLASH_ODD_ADDRESS_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(NULL == callbackHandler) + { + flashReturnStatus = FLASH_INVALID_CALLBACK_HANDLER; + } + else if(0U != NVMCONbits.WR) + { + flashReturnStatus = FLASH_OP_BUSY; + } + else + { + // Save the handler and context to call for completion of this operation. + userCallbackHandler = callbackHandler; + userContext = context; + lock = true; + bool status = FLASH_NonBlockingWriteRow24(flashAddress, data, unlockKey); + if(!status) + { + lock = false; + flashReturnStatus = FLASH_WRITE_ERROR; + } + } + } + return flashReturnStatus; +} + + +enum FLASH_RETURN_STATUS FLASH_NonBlockingRead(flash_adr_t flashAddress, size_t count, flash_data_t *data) +{ + enum FLASH_RETURN_STATUS flashReturnStatus = FLASH_OP_BUSY; + if(false == lock) + { + if ((NULL == data) || (0 == count)) + { + flashReturnStatus = FLASH_INVALID_DATA; + } + else if (0U != ((uint16_t)flashAddress & FLASH_ODD_ADDRESS_MASK)) + { + flashReturnStatus = FLASH_INVALID_ADDRESS; + } + else if(0U == NVMCONbits.WR) + { + lock = true; + do + { + *data++ = FLASH_NonBlockingReadWord24(flashAddress); + flashAddress = flashAddress + FLASH_PC_UNIT_SIZE; + } while(--count); + + flashReturnStatus = FLASH_NO_ERROR; + + // Now that the read is done, the lock can be cleared. + lock = false; + } + } + return flashReturnStatus; +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/clock.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/clock.h new file mode 100644 index 0000000..a8c328e --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/clock.h @@ -0,0 +1,90 @@ +/** + * CLOCK Generated Driver Header File + * + * @file clock.h + * + * @defgroup clockdriver Clock Driver + * + * @brief Clock configurator driver for System and Peripheral Clock using dsPIC MCUs. + * + * @version Firmware Driver Version 1.0.2 + * + * @version PLIB Version 1.4.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef CLOCK_H +#define CLOCK_H + +// Section: Included Files + +#include + +/** + @ingroup clockdriver + @brief This macro is used to read the System clock (FOSC) Frequency configured in + the MCC Melody User Interface +*/ +#define CLOCK_SystemFrequencyGet() (8000000UL) + +/** + @ingroup clockdriver + @brief This macro is used to read the Peripheral Clock (FP) Frequency + configured in the MCC Melody User Interface +*/ +#define CLOCK_PeripheralFrequencyGet() ((uint32_t)CLOCK_SystemFrequencyGet() / (uint32_t)2) + +/** + @ingroup clockdriver + @brief This macro is used to read the Instruction Clock (FCY) Frequency + configured in the MCC Melody User Interface +*/ +#define CLOCK_InstructionFrequencyGet() ((uint32_t)CLOCK_SystemFrequencyGet() / (uint32_t)2) + +// Section: CLOCK APIs + +/** + * @ingroup clockdriver + * @brief Initializes all the INTERNAL OSCILLATOR sources and clock switch configurations. + * @return none + */ +void CLOCK_Initialize(void); + +/** + * @ingroup clockdriver + * @brief Returns Auxiliary PLL status + * @pre \ref CLOCK_Initialize() should be called for the associated + * function to work. + * @return true - Auxiliary PLL locked + * @return false - Auxiliary PLL not locked + */ +bool CLOCK_AuxPllLockStatusGet(void); + +#endif /* CLOCK_H */ +/** + End of File +*/ + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/dmt.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/dmt.h new file mode 100644 index 0000000..93ff4e9 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/dmt.h @@ -0,0 +1,169 @@ +/** + * DMT Generated Driver Header File + * + * @file dmt.h + * + * @defgroup dmtdriver DMT Driver + * + * @brief Deadman Timer (DMT) driver using dsPIC MCUs. The functionality + * is to interrupt the processor in the event of a software + * malfunction. + * + * @skipline @version Firmware Driver Version 1.2.1 + * + * @skipline @version PLIB Version 1.1.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef DMT_H +#define DMT_H + +// Section: Included Files +#include +#include + +// Section: DMT APIs + +/** + * @ingroup dmtdriver + * @brief Initializes the DMT module + * @param none + * @return none + */ +void DMT_Initialize ( void ); + +/** + * @ingroup dmtdriver + * @brief Writes the PreClear Pattern for DMTPRECLR register. + * @pre This function should be called before calling \ref DMT_Clear + * @param none + * @return none + */ +void DMT_PreClear(void); + +/** + * @ingroup dmtdriver + * @brief Enables the DMT module + * @param none + * @return none + */ +void DMT_Enable(void); + +/** + * @ingroup dmtdriver + * @brief Checks the PreClear Status and clears the DMT Fetch Counter + * @pre \ref DMT_PreClear() should be called for the associated function to work + * @param none + * @return none + */ +void DMT_Clear(void); + +/** + * @ingroup dmtdriver + * @brief Returns the Window Open status + * @param none + * @return true - Window Open status bit is set + * @return false - Window Open status bit is not set + */ +bool DMT_IsWindowOpen(void); + +/** + * @ingroup dmtdriver + * @brief Checks for the PreClear sequence was initiated and + * done before the Clear sequence is done. + * @param none + * @return true - PreClear sequence performed successfully + * @return false - PreClear sequence failed + */ +bool DMT_IsPreCleared(void); + +/** + * @ingroup dmtdriver + * @brief Reads the DMT counter register + * @param none + * @return 32 bit timeout counter value + */ +uint32_t DMT_TimeoutCounterGet(void); + +/** + * @ingroup dmtdriver + * @brief Reads the DMT Window Interval Counter + * @param none + * @return 32-bit window interval counter value + */ +uint32_t DMT_WindowTimeoutCounterGet(void); + +/** + * @ingroup dmtdriver + * @brief Gets the DMT status + * @param none + * @return status value of DMT + */ +uint16_t DMT_StatusGet(void); + +/** + * @ingroup dmtdriver + * @brief Returns the current counter value + * @pre Value will not be compensated for the instructions involved in + * call-stack-push, reading SFR and call-stack-pop operations. + * @param none + * @return Returns the 32 bit counter value + */ +uint32_t DMT_CounterGet(void); + +/** + * @ingroup dmtdriver + * @brief Returns the current counter value + * @pre Value will be compensated for the instructions involved in + * call-stack-push, reading SFR and call-stack-pop operations. + * @param none + * @return Returns the 32 bit counter value + */ +uint32_t DMT_CalibratedCounterGet(void); + +/** + * @ingroup dmtdriver + * @brief This function can be used to override default callback and to define + * custom callback for DMT Event event. + * @param[in] handler - Address of the callback function. + * @return none + */ +void DMT_EventCallbackRegister(void (*handler)(void)); + +/** + * @ingroup dmtdriver + * @brief This is the default callback with weak attribute. The user can + * override and implement the default callback without weak attribute + * or can register a custom callback function using \ref DMT_EventCallbackRegister. + * @param none + * @return none + */ +void DMT_EventCallback(void); + +#endif // DMT.h + + + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/interrupt.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/interrupt.h new file mode 100644 index 0000000..de8a6d1 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/interrupt.h @@ -0,0 +1,93 @@ +/** + * INTERRUPT Generated Driver Header File + * + * @file interrupt.h + * + * @defgroup interruptdriver Interrupt Driver + * + * @brief Interrupt Priority configuration driver using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.1.2 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef INTERRUPT_H +#define INTERRUPT_H + +// Section: Driver Interface Function + +/** + * @ingroup interruptdriver + * @brief Initializes the interrupt priorities of the modules that have been configured + * @param none + * @return none + */ +void INTERRUPT_Initialize(void); + +/** + * @ingroup interruptdriver + * @brief Deinitializes the INTERRUPT to POR values + * @param none + * @return none + */ +void INTERRUPT_Deinitialize(void); + +/** + * @ingroup interruptdriver + * @brief Enables the global interrupt bit + * @param none + * @return none + */ +inline static void INTERRUPT_GlobalEnable(void) +{ + __builtin_enable_interrupts(); +} + +/** + * @ingroup interruptdriver + * @brief Disables the global interrupt bit + * @param none + * @return none + */ +inline static void INTERRUPT_GlobalDisable(void) +{ + __builtin_disable_interrupts(); +} + +/** + * @ingroup interruptdriver + * @brief Returns the pending Interrupt Vector number + * @param none + * @return Returns the pending Interrupt Vector number + */ +inline static uint16_t INTERRUPT_VectorNumberGet(void) +{ + return _VECNUM; +} + +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/interrupt_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/interrupt_types.h new file mode 100644 index 0000000..5423e70 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/interrupt_types.h @@ -0,0 +1,60 @@ +/** + * INTERRUPT Generated Driver Header File + * + * @file interrupt_types.h + * + * @defgroup interruptdriver + * + * @brief This is the generated driver types header file for the INTERRUPT driver + * + * @skipline @version Firmware Driver Version 1.1.2 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef INTERRUPT_TYPES_H +#define INTERRUPT_TYPES_H + +/** + * @ingroup interruptdriver + * @enum interrupt_types.h + * @brief Defines the interrupt priority values. +*/ + +enum INTERRUPT_PRIORITY +{ + INTERRUPT_PRIORITY_1 = 1, + INTERRUPT_PRIORITY_2 = 2, + INTERRUPT_PRIORITY_3 = 3, + INTERRUPT_PRIORITY_4 = 4, + INTERRUPT_PRIORITY_5 = 5, + INTERRUPT_PRIORITY_6 = 6, + INTERRUPT_PRIORITY_7 = 7, + INTERRUPT_MAX_PRIORITY = 7 +}; + +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/pins.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/pins.h new file mode 100644 index 0000000..4ec030e --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/pins.h @@ -0,0 +1,158 @@ +/** + * PINS Generated Driver Header File + * + * @file pins.h + * + * @defgroup pinsdriver Pins Driver + * + * @brief The Pin Driver directs the operation and function of + * the selected device pins using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.2 + * + * @skipline @version PLIB Version 1.3.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef PINS_H +#define PINS_H +// Section: Includes +#include + +// Section: Device Pin Macros + +/** + * @ingroup pinsdriver + * @brief Sets the RE5 GPIO Pin which has a custom name of LED1 to High + * @pre The RE5 must be set as Output Pin + * @param none + * @return none + */ +#define LED1_SetHigh() (_LATE5 = 1) + +/** + * @ingroup pinsdriver + * @brief Sets the RE5 GPIO Pin which has a custom name of LED1 to Low + * @pre The RE5 must be set as Output Pin + * @param none + * @return none + */ +#define LED1_SetLow() (_LATE5 = 0) + +/** + * @ingroup pinsdriver + * @brief Toggles the RE5 GPIO Pin which has a custom name of LED1 + * @pre The RE5 must be set as Output Pin + * @param none + * @return none + */ +#define LED1_Toggle() (_LATE5 ^= 1) + +/** + * @ingroup pinsdriver + * @brief Reads the value of the RE5 GPIO Pin which has a custom name of LED1 + * @param none + * @return none + */ +#define LED1_GetValue() _RE5 + +/** + * @ingroup pinsdriver + * @brief Configures the RE5 GPIO Pin which has a custom name of LED1 as Input + * @param none + * @return none + */ +#define LED1_SetDigitalInput() (_TRISE5 = 1) + +/** + * @ingroup pinsdriver + * @brief Configures the RE5 GPIO Pin which has a custom name of LED1 as Output + * @param none + * @return none + */ +#define LED1_SetDigitalOutput() (_TRISE5 = 0) + +/** + * @ingroup pinsdriver + * @brief Sets the RE6 GPIO Pin which has a custom name of LED2 to High + * @pre The RE6 must be set as Output Pin + * @param none + * @return none + */ +#define LED2_SetHigh() (_LATE6 = 1) + +/** + * @ingroup pinsdriver + * @brief Sets the RE6 GPIO Pin which has a custom name of LED2 to Low + * @pre The RE6 must be set as Output Pin + * @param none + * @return none + */ +#define LED2_SetLow() (_LATE6 = 0) + +/** + * @ingroup pinsdriver + * @brief Toggles the RE6 GPIO Pin which has a custom name of LED2 + * @pre The RE6 must be set as Output Pin + * @param none + * @return none + */ +#define LED2_Toggle() (_LATE6 ^= 1) + +/** + * @ingroup pinsdriver + * @brief Reads the value of the RE6 GPIO Pin which has a custom name of LED2 + * @param none + * @return none + */ +#define LED2_GetValue() _RE6 + +/** + * @ingroup pinsdriver + * @brief Configures the RE6 GPIO Pin which has a custom name of LED2 as Input + * @param none + * @return none + */ +#define LED2_SetDigitalInput() (_TRISE6 = 1) + +/** + * @ingroup pinsdriver + * @brief Configures the RE6 GPIO Pin which has a custom name of LED2 as Output + * @param none + * @return none + */ +#define LED2_SetDigitalOutput() (_TRISE6 = 0) + +/** + * @ingroup pinsdriver + * @brief Initializes the PINS module + * @param none + * @return none + */ +void PINS_Initialize(void); + + + +#endif diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/reset.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/reset.h new file mode 100644 index 0000000..9730d08 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/reset.h @@ -0,0 +1,76 @@ +/** + * RESET Generated Driver Header File + * + * @file reset.h + * + * @defgroup resetdriver Reset Driver + * + * @brief Reset driver using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.1.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef RESET_H +#define RESET_H + +#include +#include "reset_types.h" + +/** + * @ingroup resetdriver + * @brief Returns the cause of previous reset + * @pre This function should be called before any use of CLRWDT + * since it has a side-effect of clearing the appropriate bits in the + * register showing reset cause. + * @param none + * @return Returns a value corresponding to a possible cause for reset. + */ +uint16_t RESET_CauseGet(void); + +/** + * @ingroup resetdriver + * @brief It handles the reset cause by clearing the cause register values. + * This is a weak attribute function. The user can + * override and implement the same function without weak attribute. + * @param none + * @return none + */ +void RESET_CauseHandler(void); + +/** + * @ingroup resetdriver + * @brief Clears the Reset Cause register + * @param none + * @return none + */ +void RESET_CauseClearAll(void); + +#endif /* RESET_H */ +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/reset_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/reset_types.h new file mode 100644 index 0000000..6833a27 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/reset_types.h @@ -0,0 +1,74 @@ +/** + * RESET Generated Driver Types Header File + * + * @file reset_types.h + * + * @ingroup resetdriver + * + * @brief This is the generated driver types header file for the RESET driver + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.1.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef RESET_TYPES_H +#define RESET_TYPES_H + +/** + @ingroup resetdriver + @enum RESET_TYPES + @brief Defines the RCON error types +*/ +enum RESET_TYPES +{ + RESET_ERROR_RCON_TRAPR = 1, /**< A Trap Conflict Reset has occurred */ + RESET_ERROR_RCON_IOPUWR = 2, /**< An illegal opcode detection, an illegal address mode or Uninitialized W register used as an Address Pointer caused a Reset */ + RESET_ERROR_RCON_CM = 3, /**< A Configuration Mismatch Reset has occurred */ + RESET_ERROR_RCON_WDTO_ISR = 4 /**< WDT time-out has occurred */ +}; + +/** + @ingroup resetdriver + @enum RESET_MASKS + @brief Defines the RESET cause mask location +*/ +enum RESET_MASKS +{ + RESET_MASK_POR = 0x0001, /**< Defines the power ON Reset flag mask location */ + RESET_MASK_WDTO = 0x0010, /**< Defines the watchdog timeout reset flag mask location */ + RESET_MASK_SWR = 0x0040, /**< Defines the software reset mask location */ + RESET_MASK_EXTR = 0x0080, /**< Defines the external reset mask location */ + RESET_MASK_CM = 0x0200, /**< Defines the configuration mismatch reset mask location */ + RESET_MASK_IOPUWR = 0x4000, /**< Defines the illegal opcode or uninitialized W access reset mask location */ + RESET_MASK_TRAPR = 0x8000, /**< Defines the trap reset mask location */ +}; + +#endif /* RESET_TYPES_H */ + +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/clock.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/clock.c new file mode 100644 index 0000000..b84fa25 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/clock.c @@ -0,0 +1,103 @@ +/** + * CLOCK Generated Driver Source File + * + * @file clock.c + * + * @ingroup clockdriver + * + * @brief This is the generated source file for CLOCK driver + * + * @version Firmware Driver Version 1.0.2 + * + * @version PLIB Version 1.4.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Includes +#include +#include +#include "../clock.h" + +void CLOCK_Initialize(void) +{ + /* + Input frequency : 8.00 MHz + Clock source : FRC Oscillator + System frequency (Fosc) : 8.00 MHz + Clock switching enabled : false + Auxiliary clock source : FRC Oscillator + Auxiliary clock input frequency : 8.00 MHz + Auxiliary clock PLL output frequency (AFpllo) : 8.00 MHz + */ + // RCDIV FRC/1; PLLPRE 1:1; DOZE 1:8; DOZEN disabled; ROI disabled; + CLKDIV = 0x3001; + // PLLDIV 150; + PLLFBD = 0x96; + // TUN Center frequency; + OSCTUN = 0x0; + // PLLPOST 1:4; VCODIV FVCO/4; POST2DIV 1:1; + PLLDIV = 0x41; + // ENAPLL disabled; FRCSEL FRC Oscillator; APLLPRE 1:1; + ACLKCON1 = 0x101; + // APLLFBDIV 150; + APLLFBD1 = 0x96; + // APSTSCLR 1:4; APOST2DIV 1:1; AVCODIV FVCO/4; + APLLDIV1 = 0x41; + // CANCLKEN disabled; CANCLKSEL FVCO/4; CANCLKDIV Divide by 1; + CANCLKCON = 0x500; + // ROEN disabled; DIVSWEN disabled; ROSLP disabled; ROSEL ; OE disabled; ROSIDL disabled; + REFOCONL = 0x0; + // RODIV 0; + REFOCONH = 0x0; + // ROTRIM 0; + REFOTRIMH = 0x0; + // IOLOCK disabled; + RPCON = 0x0; + // PMDLOCK disabled; + PMDCON = 0x0; + // ADC1MD enabled; T1MD enabled; U2MD enabled; U1MD enabled; SPI2MD enabled; SPI1MD enabled; QEIMD enabled; PWMMD enabled; I2C1MD enabled; C1MD enabled; + PMD1 = 0x0; + // CCP2MD enabled; CCP1MD enabled; CCP4MD enabled; CCP3MD enabled; CCP7MD enabled; CCP8MD enabled; CCP5MD enabled; CCP6MD enabled; CCP9MD enabled; + PMD2 = 0x0; + // U3MD enabled; CRCMD enabled; I2C2MD enabled; I2C3MD enabled; QEI2MD enabled; PMPMD enabled; + PMD3 = 0x0; + // REFOMD enabled; + PMD4 = 0x0; + // DMA1MD enabled; DMA2MD enabled; DMA3MD enabled; DMA0MD enabled; SPI3MD enabled; + PMD6 = 0x0; + // PTGMD enabled; CMP1MD enabled; CMP3MD enabled; CMP2MD enabled; + PMD7 = 0x0; + // DMTMD enabled; CLC3MD enabled; OPAMPMD enabled; BIASMD enabled; CLC4MD enabled; SENT1MD enabled; CLC1MD enabled; CLC2MD enabled; SENT2MD enabled; + PMD8 = 0x0; + // CF no clock failure; NOSC FRC; CLKLOCK unlocked; OSWEN Switch is Complete; + __builtin_write_OSCCONH((uint8_t) (0x00)); + __builtin_write_OSCCONL((uint8_t) (0x00)); +} + +bool CLOCK_AuxPllLockStatusGet(void) +{ + return ACLKCON1bits.APLLCK; +} + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/config_bits.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/config_bits.c new file mode 100644 index 0000000..c2360a1 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/config_bits.c @@ -0,0 +1,118 @@ +/** + * CONFIGURATION_BITS Generated Driver Source File + * + * @file configuration_bits.c + * + * @defgroup config_bitsdriver CONFIGBITS Driver + * + * @brief Device Configuration Bits using dsPIC MCUs + * + * @version Firmware Driver Version 1.0.1 + * + * @version PLIB Version 1.2.2 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Configuration bits: selected in the GUI + +// FSEC +#pragma config BWRP = OFF //Boot Segment Write-Protect bit->Boot Segment may be written +#pragma config BSS = DISABLED //Boot Segment Code-Protect Level bits->No Protection (other than BWRP) +#pragma config BSEN = OFF //Boot Segment Control bit->No Boot Segment +#pragma config GWRP = OFF //General Segment Write-Protect bit->General Segment may be written +#pragma config GSS = DISABLED //General Segment Code-Protect Level bits->No Protection (other than GWRP) +#pragma config CWRP = OFF //Configuration Segment Write-Protect bit->Configuration Segment may be written +#pragma config CSS = DISABLED //Configuration Segment Code-Protect Level bits->No Protection (other than CWRP) +#pragma config AIVTDIS = OFF //Alternate Interrupt Vector Table bit->Disabled AIVT + +// FBSLIM +#pragma config BSLIM = 0x1fff //Boot Segment Flash Page Address Limit bits + +// FOSCSEL +#pragma config FNOSC = FRC //Oscillator Source Selection->Internal Fast RC (FRC) +#pragma config IESO = OFF //Two-speed Oscillator Start-up Enable bit->Start up with user-selected oscillator source + +// FOSC +#pragma config POSCMD = NONE //Primary Oscillator Mode Select bits->Primary Oscillator disabled +#pragma config OSCIOFNC = ON //OSC2 Pin Function bit->OSC2 is general purpose digital I/O pin +#pragma config FCKSM = CSDCMD //Clock Switching Mode bits->Both Clock switching and Fail-safe Clock Monitor are disabled +#pragma config PLLKEN = ON //PLL Lock Status Control->PLL lock signal will be used to disable PLL clock output if lock is lost +#pragma config XTCFG = G3 //XT Config->24-32 MHz crystals +#pragma config XTBST = ENABLE //XT Boost->Boost the kick-start + +// FWDT +#pragma config RWDTPS = PS1048576 //Run Mode Watchdog Timer Post Scaler select bits->1:1048576 +#pragma config RCLKSEL = LPRC //Watchdog Timer Clock Select bits->Always use LPRC +#pragma config WINDIS = ON //Watchdog Timer Window Enable bit->Watchdog Timer in Non-Window mode +#pragma config WDTWIN = WIN25 //Watchdog Timer Window Select bits->WDT Window is 25% of WDT period +#pragma config SWDTPS = PS1048576 //Sleep Mode Watchdog Timer Post Scaler select bits->1:1048576 +#pragma config FWDTEN = ON_SW //Watchdog Timer Enable bit->WDT controlled via SW, use WDTCON.ON bit + +// FPOR +#pragma config BISTDIS = DISABLED //Memory BIST Feature Disable->mBIST on reset feature disabled + +// FICD +#pragma config ICS = PGD1 //ICD Communication Channel Select bits->Communicate on PGC1 and PGD1 +#pragma config JTAGEN = OFF //JTAG Enable bit->JTAG is disabled +#pragma config NOBTSWP = DISABLED //BOOTSWP instruction disable bit->BOOTSWP instruction is disabled + +// FDMTIVTL +#pragma config DMTIVTL = 0x0 //Dead Man Timer Interval low word + +// FDMTIVTH +#pragma config DMTIVTH = 0x0 //Dead Man Timer Interval high word + +// FDMTCNTL +#pragma config DMTCNTL = 0x0 //Lower 16 bits of 32 bit DMT instruction count time-out value (0-0xFFFF) + +// FDMTCNTH +#pragma config DMTCNTH = 0x0 //Upper 16 bits of 32 bit DMT instruction count time-out value (0-0xFFFF) + +// FDMT +#pragma config DMTDIS = OFF //Dead Man Timer Disable bit->Dead Man Timer is Disabled and can be enabled by software + +// FDEVOPT +#pragma config ALTI2C1 = OFF //Alternate I2C1 Pin bit->I2C1 mapped to SDA1/SCL1 pins +#pragma config ALTI2C2 = OFF //Alternate I2C2 Pin bit->I2C2 mapped to SDA2/SCL2 pins +#pragma config ALTI2C3 = OFF //Alternate I2C3 Pin bit->I2C3 mapped to SDA3/SCL3 pins +#pragma config SMBEN = SMBUS //SM Bus Enable->SMBus input threshold is enabled +#pragma config SPI2PIN = PPS //SPI2 Pin Select bit->SPI2 uses I/O remap (PPS) pins + +// FALTREG +#pragma config CTXT1 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 1 bits->Not Assigned +#pragma config CTXT2 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 2 bits->Not Assigned +#pragma config CTXT3 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 3 bits->Not Assigned +#pragma config CTXT4 = OFF //Specifies Interrupt Priority Level (IPL) Associated to Alternate Working Register 4 bits->Not Assigned + +// FBTSEQ +#pragma config BSEQ = 0x003 //Relative value defining which partition will be active after device Reset; the partition containing a lower boot number will be active +#pragma config IBSEQ = 0xFFC //The one's complement of BSEQ; must be calculated by the user and written during device programming. + +// FBOOT +#pragma config BTMODE = DUAL //Device Boot Mode Configuration->Device is in Dual Partition mode + +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/dmt.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/dmt.c new file mode 100644 index 0000000..ffc639f --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/dmt.c @@ -0,0 +1,159 @@ +/** + * DMT Generated Driver Source File + * + * @file dmt.c + * + * @ingroup dmtdriver + * + * @brief This is the generated driver source file for DMT driver + * + * @skipline @version Firmware Driver Version 1.2.1 + * + * @skipline @version PLIB Version 1.1.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Included Files +#include +#include +#include "../dmt.h" +#include "../interrupt.h" + +// Section: Private Variable Definitions +static bool bPreCleared = false; +uint32_t calibOffset = 0; +static void (*DMT_EventHandler)(void) = NULL; + +// Section: File specific functions + +void DMT_Calibrate(void); + +// Section: DMT Module APIs +void DMT_Initialize(void) +{ + INTERRUPT_GlobalDisable(); + DMT_Calibrate(); + INTERRUPT_GlobalEnable(); + + DMT_EventCallbackRegister(&DMT_EventCallback); + + IEC2bits.DMTIE = 1U; +} + +void DMT_Enable(void) +{ + // Set the Bit ON = 1 + DMTCON = 0x8000; +} + +void DMT_PreClear(void) +{ + DMTPRECLR = 0x4000; + + // To keep track of Preclear operation is performed + bPreCleared = true; +} + +void DMT_Clear(void) +{ + bPreCleared = false; + while((DMTSTAT & 0x0001) != 0x0001) + { + } + + DMTCLR = 0x0008; +} + +bool DMT_IsWindowOpen(void) +{ + bool status = false; + + if((DMTSTAT & 0x0001) == 0x0001) + { + status = true; + } + + return status; +} + +bool DMT_IsPreCleared(void) +{ + return bPreCleared; +} + +uint32_t DMT_TimeoutCounterGet(void) +{ + uint32_t counter = 0; + counter = (uint32_t)(DMTPSCNTH & 0x0000FFFF) << 16; + return (counter | DMTPSCNTL); +} + +uint32_t DMT_WindowTimeoutCounterGet(void) +{ + uint32_t winTimeoutCounter = 0; + winTimeoutCounter = (uint32_t)(DMTPSINTVH & 0x0000FFFF) << 16; + return (winTimeoutCounter | DMTPSINTVL); +} + +uint16_t DMT_StatusGet(void) +{ + uint16_t status = 0; + status = (uint16_t)(DMTSTAT & 0xE1); + return status; +} + +uint32_t DMT_CounterGet(void) +{ + uint32_t counter = 0; + counter = (uint32_t)(DMTCNTH & 0x0000FFFF) << 16; + return (counter | DMTCNTL); +} + +void DMT_EventCallbackRegister(void (*handler)(void)) +{ + if(NULL != handler) + { + DMT_EventHandler = handler; + } +} + +void __attribute__ ((weak)) DMT_EventCallback( void ) +{ + +} + + +void __attribute__ ((interrupt, no_auto_psv)) _DMTInterrupt(void) +{ + if(NULL != DMT_EventHandler) + { + (*DMT_EventHandler)(); + } + IFS2bits.DMTIF = 0U; +} + +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/dmt_asm.s b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/dmt_asm.s new file mode 100644 index 0000000..a72679f --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/dmt_asm.s @@ -0,0 +1,113 @@ +;/******************************************************************************* +; +;DMT Generated Driver Header File +; +; @file dmt_asm.s +; +; @defgroup dmtdriver DMT Driver +; +; @brief Assembly language optimized helper routines required for calibration +; +; @skipline @version Firmware Driver Version 1.2.1 +; +; @skipline @version PLIB Version 1.1.1 +; +; @skipline Device : dsPIC33CK256MP508 +; +;*******************************************************************************/ +; +;// DOM-IGNORE-BEGIN +;/******************************************************************************* +; Copyright (C) 2016 Microchip Technology Inc. +; +; MICROCHIP SOFTWARE NOTICE AND DISCLAIMER: You may use this software, and any +; derivatives created by any person or entity by or on your behalf, exclusively +; with Microchip's products. Microchip and its licensors retain all ownership +; and intellectual property rights in the accompanying software and in all +; derivatives here to. +; +; This software and any accompanying information is for suggestion only. It +; does not modify Microchip's standard warranty for its products. You agree +; that you are solely responsible for testing the software and determining its +; suitability. Microchip has no obligation to modify, test, certify, or +; support the software. +; +; THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER +; EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED +; WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR +; PURPOSE APPLY TO THIS SOFTWARE, ITS INTERACTION WITH MICROCHIP'S PRODUCTS, +; COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. +; +; IN NO EVENT, WILL MICROCHIP BE LIABLE, WHETHER IN CONTRACT, WARRANTY, TORT +; (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY), STRICT LIABILITY, +; INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, SPECIAL, PUNITIVE, +; EXEMPLARY, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, FOR COST OR EXPENSE OF +; ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWSOEVER CAUSED, EVEN IF +; MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. +; TO THE FULLEST EXTENT ALLOWABLE BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL +; CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF +; FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. +; +; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE +; TERMS. +;*******************************************************************************/ + + +/** + * ;uint32_t DMT_CalibratedCounterGet(void); + * Gets the count of DMT counter just before calling CalibratedCounterGet function + * + * @param none + * @return 32-bit (unsigned long) caliberated count + * + * Registers used: w0 w1 w2 + * + */ + + .global _DMT_CounterGet + .global _DMT_CalibratedCounterGet + .global _calibOffset + .type _DMT_CalibratedCounterGet, @function + reset + + _DMT_CalibratedCounterGet: + call _DMT_CounterGet + push w2 + mov _calibOffset, w2 + SUBR w2, w0, w0 + mov #0x0, w2 + SUBBR w2, w1, w1 + pop w2 + return + +/** + * ;void DMT_Calibrate(void); + * Calculates and stores offset value during DMT_CounterGet function call + * + * Registers used: w0 w1 w2 + * + */ + + .global _DMT_CounterGet + .global _DMT_Calibrate + .global _calibOffset + .type _DMT_Calibrate, @function + .extern DMTCNTL + reset + + _DMT_Calibrate: + push w0 + push w1 + push w2 + mov DMTCNTL, w0 + push w0 + call _DMT_CounterGet + pop w2 + sub w0, w2, w2 + dec w2, w2 + mov w2, _calibOffset + pop w2 + pop w1 + pop w0 + return + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/interrupt.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/interrupt.c new file mode 100644 index 0000000..b57eafa --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/interrupt.c @@ -0,0 +1,61 @@ +/** + * INTERRUPT Generated Driver Source File + * + * @file interrupt.c + * + * @ingroup interruptdriver + * + * @brief This is the generated driver source file for INTERRUPT driver + * + * @skipline @version Firmware Driver Version 1.1.2 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Includes +#include +#include "../interrupt.h" + +// Section: Driver Interface Function Definitions + +void INTERRUPT_Initialize(void) +{ + // DMT: Dead Man Timer + // Priority: 1 + IPC11bits.DMTIP = 1; + + // NVM: NVM Write complete + // Priority: 1 + IPC3bits.NVMIP = 1; + +} + +void INTERRUPT_Deinitialize(void) +{ + //POR default value of priority + IPC11bits.DMTIP = 4; + IPC3bits.NVMIP = 4; +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/pins.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/pins.c new file mode 100644 index 0000000..8873589 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/pins.c @@ -0,0 +1,113 @@ +/** + * PINS Generated Driver Source File + * + * @file pins.c + * + * @ingroup pinsdriver + * + * @brief This is the generated driver source file for PINS driver. + * + * @skipline @version Firmware Driver Version 1.0.2 + * + * @skipline @version PLIB Version 1.3.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Includes +#include +#include +#include "../pins.h" + +// Section: File specific functions + +// Section: Driver Interface Function Definitions +void PINS_Initialize(void) +{ + /**************************************************************************** + * Setting the Output Latch SFR(s) + ***************************************************************************/ + LATA = 0x0000; + LATB = 0x0000; + LATC = 0x0000; + LATD = 0x0010; + LATE = 0x0000; + + /**************************************************************************** + * Setting the GPIO Direction SFR(s) + ***************************************************************************/ + TRISA = 0x001F; + TRISB = 0xFFFF; + TRISC = 0xFFFF; + TRISD = 0xFFEF; + TRISE = 0xFF9F; + + + /**************************************************************************** + * Setting the Weak Pull Up and Weak Pull Down SFR(s) + ***************************************************************************/ + CNPUA = 0x0000; + CNPUB = 0x0000; + CNPUC = 0x0000; + CNPUD = 0x0000; + CNPUE = 0x0000; + CNPDA = 0x0000; + CNPDB = 0x0000; + CNPDC = 0x0000; + CNPDD = 0x0000; + CNPDE = 0x0000; + + + /**************************************************************************** + * Setting the Open Drain SFR(s) + ***************************************************************************/ + ODCA = 0x0000; + ODCB = 0x0000; + ODCC = 0x0000; + ODCD = 0x0000; + ODCE = 0x0000; + + + /**************************************************************************** + * Setting the Analog/Digital Configuration SFR(s) + ***************************************************************************/ + ANSELA = 0x001F; + ANSELB = 0x009F; + ANSELC = 0x00CF; + ANSELD = 0x2C00; + ANSELE = 0x000F; + + /**************************************************************************** + * Set the PPS + ***************************************************************************/ + __builtin_write_RPCON(0x0000); // unlock PPS + + RPINR18bits.U1RXR = 0x0043; //RD3->UART1:U1RX; + RPOR18bits.RP68R = 0x0001; //RD4->UART1:U1TX; + + __builtin_write_RPCON(0x0800); // lock PPS + + +} + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/reset.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/reset.c new file mode 100644 index 0000000..3d0d850 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/reset.c @@ -0,0 +1,204 @@ +/** + * RESET Generated Driver Source File + * + * @file reset.c + * + * @ingroup resetdriver + * + * @brief This is the generated driver source file for RESET driver + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.1.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include +#include +#include +#include "../reset.h" + +// Section: File specific functions + + +/** + @ingroup resetdriver + @static RESET cause from trap + @brief RESET cause from trap +*/ +static bool RESET_CauseFromTrap(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_TRAPR) == (uint16_t) RESET_MASK_TRAPR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Illegal Opcode + @brief RESET cause from Illegal Opcode +*/ +static bool RESET_CauseFromIllegalOpcode(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_IOPUWR) == (uint16_t) RESET_MASK_IOPUWR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Configuration Mismatch + @brief RESET cause from Configuration Mismatch +*/ +static bool RESET_CauseFromConfigurationMismatch(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_CM) == (uint16_t) RESET_MASK_CM) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from External + @brief RESET cause from External +*/ +static bool RESET_CauseFromExternal(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_EXTR) == (uint16_t) RESET_MASK_EXTR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Software + @brief RESET cause from Software +*/ +static bool RESET_CauseFromSoftware(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_SWR) == (uint16_t) RESET_MASK_SWR) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Watchdog Time + @brief RESET cause from Watchdog Time +*/ +static bool RESET_CauseFromWatchdogTimer(uint16_t resetCause) +{ + bool resetStatus = false; + + if((uint16_t)(resetCause & (uint16_t) RESET_MASK_WDTO) == (uint16_t) RESET_MASK_WDTO) + { + resetStatus = true; + } + + return resetStatus; +} + +/** + @ingroup resetdriver + @static RESET cause from Clear + @brief RESET cause from Clear +*/ +static void RESET_CauseClear(enum RESET_MASKS resetFlagMask) +{ + RCON = RCON & (~resetFlagMask); +} + +uint16_t RESET_CauseGet(void) +{ + return RCON; +} + +void __attribute__ ((weak)) RESET_CauseHandler(void) +{ + uint16_t resetCause = RESET_CauseGet(); + + if(RESET_CauseFromTrap(resetCause)) + { + RESET_CauseClear(RESET_MASK_TRAPR); + } + + if(RESET_CauseFromIllegalOpcode(resetCause)) + { + RESET_CauseClear(RESET_MASK_IOPUWR); + } + + if(RESET_CauseFromConfigurationMismatch(resetCause)) + { + RESET_CauseClear(RESET_MASK_CM); + } + + if(RESET_CauseFromExternal(resetCause)) + { + RESET_CauseClear(RESET_MASK_EXTR); + } + + if(RESET_CauseFromSoftware(resetCause)) + { + RESET_CauseClear(RESET_MASK_SWR); + } + + if(RESET_CauseFromWatchdogTimer(resetCause)) + { + RESET_CauseClear(RESET_MASK_WDTO); + } +} + +void RESET_CauseClearAll(void) +{ + RCON = 0x00; +} +/** + End of File +*/ diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/system.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/system.c new file mode 100644 index 0000000..736ece1 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/system.c @@ -0,0 +1,58 @@ +/** + * MAIN Generated Driver Header File + * + * @file system.c + * + * @ingroup systemdriver + * + * @brief This is the generated driver header file for the System driver + * + * @version Driver Version 1.0.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include "../system.h" +#include "../system_types.h" +#include "../clock.h" +#include "../pins.h" +#include "../dmt.h" +#include "../../flash/flash_nonblocking.h" +#include "../../uart/uart1.h" +#include "../interrupt.h" + + +void SYSTEM_Initialize(void) +{ + CLOCK_Initialize(); + PINS_Initialize(); + DMT_Initialize(); + FLASH_Initialize(); + UART1_Initialize(); + INTERRUPT_GlobalEnable(); + INTERRUPT_Initialize(); +} + +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/traps.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/traps.c new file mode 100644 index 0000000..be2fe71 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/src/traps.c @@ -0,0 +1,168 @@ +/** + * TRAPS Generated Driver Source File + * + * @file traps.c + * + * @ingroup trapsdriver + * + * @brief This is the generated driver source file for TRAPS driver + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Included Files +#include +#include "../traps.h" + +#define ERROR_HANDLER __attribute__((interrupt,no_auto_psv)) +#define FAILSAFE_STACK_GUARDSIZE 8 + +// A private place to store the error code if we run into a severe error + +static uint16_t TRAPS_error_code = -1; + +// Section: Driver Interface Function Definitions + +//@brief Halts +void __attribute__((weak)) TRAPS_halt_on_error(uint16_t code) +{ + TRAPS_error_code = code; +#ifdef __DEBUG + /* If we are in debug mode, cause a software breakpoint in the debugger */ + __builtin_software_breakpoint(); + while(1) + { + + } +#else + // Trigger software reset + __asm__ volatile ("reset"); +#endif +} + +// @brief Sets the stack pointer to a backup area of memory, in case we run into +// a stack error (in which case we can't really trust the stack pointer) + +inline static void use_failsafe_stack(void) +{ + static uint8_t failsafe_stack[32]; + asm volatile ( + " mov %[pstack], W15\n" + : + : [pstack]"r"(failsafe_stack) + ); + + /* Controls where the stack pointer limit is, relative to the end of the + * failsafe stack + */ + SPLIM = (uint16_t)(((uint8_t *)failsafe_stack) + sizeof(failsafe_stack) - (uint16_t) FAILSAFE_STACK_GUARDSIZE); +} + +/** Address error Trap vector**/ +void ERROR_HANDLER _AddressError(void) +{ + INTCON1bits.ADDRERR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_ADDRESS_ERR); +} + +/** Generic Hard Trap vector**/ +void ERROR_HANDLER _HardTrapError(void) +{ + INTCON4bits.SGHT = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_HARD_ERR); +} + +/** Generic Soft Trap vector**/ +void ERROR_HANDLER _SoftTrapError(void) +{ + if(INTCON3bits.DOOVR == 1) + { + INTCON3bits.DOOVR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_DOOVR_ERR); + } + +#ifdef _DAE + if(INTCON3bits.DAE == 1) + { + INTCON3bits.DAE = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_DAE_ERR); + } + +#endif + if(INTCON3bits.NAE == 1) + { + INTCON3bits.NAE = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_NVM_ERR); + } + +#ifdef _CAN + if(INTCON3bits.CAN == 1) + { + INTCON3bits.CAN = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_CAN_ERR); + } + +#endif + if(INTCON3bits.APLL == 1) + { + INTCON3bits.APLL = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_APLL_ERR); + } + + while(1) + { + } +} + +/** Oscillator Fail Trap vector**/ +void ERROR_HANDLER _OscillatorFail(void) +{ + INTCON1bits.OSCFAIL = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_OSC_FAIL); +} + +/** Math Error Trap vector**/ +void ERROR_HANDLER _MathError(void) +{ + INTCON1bits.MATHERR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_MATH_ERR); +} + +/** Stack Error Trap Vector**/ +void ERROR_HANDLER _StackError(void) +{ + /* We use a failsafe stack: the presence of a stack-pointer error + * means that we cannot trust the stack to operate correctly unless + * we set the stack pointer to a safe place. + */ + use_failsafe_stack(); + + INTCON1bits.STKERR = 0; //Clear the trap flag + TRAPS_halt_on_error(TRAPS_STACK_ERR); +} + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/system.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/system.h new file mode 100644 index 0000000..d1ac3ff --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/system.h @@ -0,0 +1,106 @@ +/** + * MAIN Generated Driver Header File + * + * @file system.h + * + * @defgroup systemdriver System Driver + * + * @brief System driver using dsPIC MCUs. + * + * @version Driver Version 1.0.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#include "xc.h" +#include "stdint.h" +#include "system_types.h" + +#ifndef SYSTEM_H +#define SYSTEM_H + +/** + * @ingroup systemdriver + * @brief Initializes the System module + * @return none + */ +void SYSTEM_Initialize(void); + +/** + * @ingroup systemdriver + * @brief Initializes the CPU core control register + * @return none + */ +inline static void SYSTEM_CORCONInitialize() +{ + CORCON = (CORCON & 0x00F2) | CORCON_MODE_PORVALUES; +} + +/** + * @ingroup systemdriver + * @brief This inline function sets the CPU core control register operating mode + * to a value that is decided by the SYSTEM_CORCON_MODES argument. + * @param[in] modeValue - SYSTEM_CORCON_MODES initialization mode specifier + * @return none + */ +inline static void SYSTEM_CORCONModeOperatingSet(SYSTEM_CORCON_MODES modeValue) +{ + CORCON = (CORCON & 0x00F2) | modeValue; +} + +/** + * @ingroup systemdriver + * @brief This inline function sets the value of CPU core control register + * @param[in] value - value that needs to be written to the CPU core control register + * @return none + */ +inline static void SYSTEM_CORCONRegisterValueSet(uint16_t value) +{ + CORCON = value; +} + +/** + * @ingroup systemdriver + * @brief This inline function gets the value of CPU core control register + * @return value of the CPU core control register + */ +inline static uint16_t SYSTEM_CORCONRegisterValueGet(void) +{ + return CORCON; +} + +/** + * @ingroup systemdriver + * @brief This inline function gets the base address of the DEVID register + * for the currently selected device + * @return base address of the DEVID register + */ +inline static uint32_t SYSTEM_DeviceIdRegisterAddressGet(void) +{ + return __DEVID_BASE; +} + +#endif /* SYSTEM_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/system_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/system_types.h new file mode 100644 index 0000000..9202d0a --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/system_types.h @@ -0,0 +1,96 @@ +/** + * MAIN Generated Driver Types Header File + * + * @file system_types.h + * + * @ingroup systemdriver + * + * @brief This is the generated driver types header file for the System driver + * + * @version Driver Version 1.0.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef SYSTEM_TYPES_H +#define SYSTEM_TYPES_H + +/** + Section: Type defines + */ + +/** + @ingroup systemdriver + @enum CORCON_MODE_TYPE + @brief CORCON initialization type enumerator +*/ +typedef enum CORCON_MODE_TYPE +{ + CORCON_MODE_PORVALUES = 0x0020, /**< Use POR values of CORCON */ + CORCON_MODE_ENABLEALLSATNORMAL_ROUNDBIASED = 0x00E2, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable normal + ACCA/ACCB saturation mode and set + rounding to Biased (conventional) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_ENABLEALLSATNORMAL_ROUNDUNBIASED = 0x00E0, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable normal + ACCA/ACCB saturation mode and set + rounding to Unbiased (convergent) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_DISABLEALLSAT_ROUNDBIASED = 0x0022, /**< Disable saturation for ACCA, ACCB + and Dataspace write and set + rounding to Biased (conventional) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_DISABLEALLSAT_ROUNDUNBIASED = 0x0020, /**< Disable saturation for ACCA, ACCB + and Dataspace write and set + rounding to Unbiased (convergent) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_ENABLEALLSATSUPER_ROUNDBIASED = 0x00F2, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable super + ACCA/ACCB saturation mode and set + rounding to Biased (conventional) + mode. Rest of CORCON settings are + set to the default POR values. + */ + CORCON_MODE_ENABLEALLSATSUPER_ROUNDUNBIASED = 0x00F0, /**< Enable saturation for ACCA, ACCB + and Dataspace write, enable super + ACCA/ACCB saturation mode and set + rounding to Unbiased (convergent) + mode. Rest of CORCON settings are + set to the default POR values. + */ +} SYSTEM_CORCON_MODES; + +#endif /* SYSTEM_TYPES_H */ +/** + End of File +*/ \ No newline at end of file diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/traps.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/traps.h new file mode 100644 index 0000000..8042675 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/traps.h @@ -0,0 +1,79 @@ +/** + * TRAPS Generated Driver Header File + * + * @file traps.h + * + * @defgroup trapsdriver Traps Driver + * + * @brief Traps driver with handler for all types of traps using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.3 + * + * @skipline @version PLIB Version 1.3.1 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef TRAPS_H +#define TRAPS_H + +// Section: Included Files +#include + +// Section: Data Type Definitions + +/** + @ingroup trapsdriver + @enum TRAPS_ERROR_CODE + @brief Defines the TRAPS error codes +*/ +enum TRAPS_ERROR_CODE +{ +// Traps + TRAPS_OSC_FAIL = 0, /**< Oscillator Fail Trap vector */ + TRAPS_STACK_ERR = 1, /**< Stack Error Trap Vector */ + TRAPS_ADDRESS_ERR = 2, /**< Address error Trap vector */ + TRAPS_MATH_ERR = 3, /**< Math Error Trap vector */ + TRAPS_HARD_ERR = 7, /**< Generic Hard Trap vector */ + TRAPS_DAE_ERR = 9, /**< Generic Soft Trap vector */ + TRAPS_DOOVR_ERR = 10, /**< Generic Soft Trap vector */ + TRAPS_APLL_ERR = 11, /**< Generic Soft Trap vector */ + TRAPS_NVM_ERR = 12, /**< Generic Soft Trap vector */ + TRAPS_CAN_ERR = 13, /**< Generic Soft Trap vector */ +}; + +// Section: Driver Interface Function + +/** + * @ingroup trapsdriver + * @brief Stores the trap error code and waits forever. + * This is a weak attribute function. The user can + * override and implement the same function without weak attribute. + * @param[in] code - trap error code + * @return none + */ +void TRAPS_halt_on_error(uint16_t code); + +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/watchdog.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/watchdog.h new file mode 100644 index 0000000..e05e530 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/system/watchdog.h @@ -0,0 +1,88 @@ +/** + * WATCHDOG Generated Driver Header File + * + * @file watchdog.h + * + * @defgroup watchdogdriver WDT Driver + * + * @brief Watchdog Timer Driver using dsPIC MCUs. + * + * @skipline @version Firmware Driver Version 1.0.2 + * + * @skipline @version PLIB Version 1.2.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef WATCHDOG_H +#define WATCHDOG_H + +#include + +// Section: Type defines + +/** + * @ingroup watchdogdriver + * @brief This macro holds the key value to clear Watchdog Timer (WDT) +*/ +#define WATCHDOG_CLR_KEY 0x5743 + +/** + * @ingroup watchdogdriver + * @brief This inline function is used to enable the Watchdog Timer (WDT) using the software bit + * @param none + * @return none + */ +inline static void WATCHDOG_TimerSoftwareEnable(void) +{ + WDTCONLbits.ON = 1; +} + +/** + * @ingroup watchdogdriver + * @brief This inline function is used to disable the Watchdog Timer (WDT) using the software bit + * @param none + * @return none + */ +inline static void WATCHDOG_TimerSoftwareDisable(void) +{ + WDTCONLbits.ON = 0; +} + +/** + * @ingroup watchdogdriver + * @brief This inline function is used to clear the Watchdog Timer (WDT) + * @param none + * @return none + */ +inline static void WATCHDOG_TimerClear(void) +{ + WDTCONH = WATCHDOG_CLR_KEY; +} + +#endif /* WATCHDOG_H */ +/** + End of File +*/ + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/src/uart1.c b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/src/uart1.c new file mode 100644 index 0000000..927b1cc --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/src/uart1.c @@ -0,0 +1,290 @@ +/** + * UART1 Generated Driver Source File + * + * @file uart1.c + * + * @ingroup uartdriver + * + * @brief This is the generated driver source file for the UART1 driver. + * + * @skipline @version Firmware Driver Version 1.7.0 + * + * @skipline @version PLIB Version 1.5.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +// Section: Included Files +#include +#include +#include +#include +#include "../uart1.h" + +// Section: Macro Definitions +#define UART1_CLOCK 4000000U +#define UART1_BAUD_TO_BRG_WITH_FRACTIONAL(x) (UART1_CLOCK/(x)) +#define UART1_BAUD_TO_BRG_WITH_BRGH_1(x) (UART1_CLOCK/(4U*(x))-1U) +#define UART1_BAUD_TO_BRG_WITH_BRGH_0(x) (UART1_CLOCK/(16U*(x))-1U) +#define UART1_BRG_TO_BAUD_WITH_FRACTIONAL(x) (UART1_CLOCK/(x)) +#define UART1_BRG_TO_BAUD_WITH_BRGH_1(x) (UART1_CLOCK/(4U*((x)+1U))) +#define UART1_BRG_TO_BAUD_WITH_BRGH_0(x) (UART1_CLOCK/(16U*((x)+1U))) + +#define UART1_MIN_ACHIEVABLE_BAUD_WITH_FRACTIONAL 4U +#define UART1_MIN_ACHIEVABLE_BAUD_WITH_BRGH_1 1U + +// Section: Driver Interface + +const struct UART_INTERFACE UART1_Drv = { + .Initialize = &UART1_Initialize, + .Deinitialize = &UART1_Deinitialize, + .Read = &UART1_Read, + .Write = &UART1_Write, + .IsRxReady = &UART1_IsRxReady, + .IsTxReady = &UART1_IsTxReady, + .IsTxDone = &UART1_IsTxDone, + .TransmitEnable = &UART1_TransmitEnable, + .TransmitDisable = &UART1_TransmitDisable, + .TransmitInterruptEnable = NULL, + .TransmitInterruptDisable = NULL, + .AutoBaudSet = &UART1_AutoBaudSet, + .AutoBaudQuery = &UART1_AutoBaudQuery, + .AutoBaudEventEnableGet = &UART1_AutoBaudEventEnableGet, + .BRGCountSet = &UART1_BRGCountSet, + .BRGCountGet = &UART1_BRGCountGet, + .BaudRateSet = &UART1_BaudRateSet, + .BaudRateGet = &UART1_BaudRateGet, + .ErrorGet = &UART1_ErrorGet, + .RxCompleteCallbackRegister = NULL, + .TxCompleteCallbackRegister = NULL, + .TxCollisionCallbackRegister = NULL, + .FramingErrorCallbackRegister = NULL, + .OverrunErrorCallbackRegister = NULL, + .ParityErrorCallbackRegister = NULL, +}; + +// Section: Private Variable Definitions +static union +{ + struct + { + uint16_t frammingError :1; + uint16_t parityError :1; + uint16_t overrunError :1; + uint16_t txCollisionError :1; + uint16_t autoBaudOverflow :1; + uint16_t reserved :11; + }; + size_t status; +} uartError; + +// Section: UART1 APIs + +void UART1_Initialize(void) +{ +/* + Set the UART1 module to the options selected in the user interface. + Make sure to set LAT bit corresponding to TxPin as high before UART initialization +*/ + // URXEN ; RXBIMD ; UARTEN disabled; MOD Asynchronous 8-bit UART; UTXBRK ; BRKOVR ; UTXEN ; USIDL ; WAKE ; ABAUD ; BRGH ; + U1MODE = 0x0; + // STSEL 1 Stop bit sent, 1 checked at RX; BCLKMOD enabled; SLPEN ; FLO ; BCLKSEL FOSC/2; C0EN ; RUNOVF ; UTXINV ; URXINV ; HALFDPLX ; + U1MODEH = 0x800; + // OERIE ; RXBKIF ; RXBKIE ; ABDOVF ; OERR ; TXCIE ; TXCIF ; FERIE ; TXMTIE ; ABDOVE ; CERIE ; CERIF ; PERIE ; + U1STA = 0x80; + // URXISEL ; UTXBE ; UTXISEL ; URXBE ; STPMD ; TXWRE ; + U1STAH = 0x2E; + // BaudRate 9592.33; Frequency 4000000 Hz; BRG 417; + U1BRG = 0x1A1; + // BRG 0; + U1BRGH = 0x0; + + U1MODEbits.UARTEN = 1; // enabling UART ON bit + U1MODEbits.UTXEN = 1; + U1MODEbits.URXEN = 1; +} + +void UART1_Deinitialize(void) +{ + U1MODE = 0x0; + U1MODEH = 0x0; + U1STA = 0x80; + U1STAH = 0x2E; + U1BRG = 0x0; + U1BRGH = 0x0; +} + +uint8_t UART1_Read(void) +{ + while((U1STAHbits.URXBE == 1)) + { + + } + + if ((U1STAbits.OERR == 1)) + { + U1STAbits.OERR = 0; + } + + return U1RXREG; +} + +void UART1_Write(uint8_t txData) +{ + while(U1STAHbits.UTXBF == 1) + { + + } + + U1TXREG = txData; // Write the data byte to the USART. +} + +bool UART1_IsRxReady(void) +{ + return (U1STAHbits.URXBE == 0); +} + +bool UART1_IsTxReady(void) +{ + return ((!U1STAHbits.UTXBF) && U1MODEbits.UTXEN); +} + +bool UART1_IsTxDone(void) +{ + return (bool)(U1STAbits.TRMT && U1STAHbits.UTXBE); +} + +void UART1_TransmitEnable(void) +{ + U1MODEbits.UTXEN = 1; +} + +void UART1_TransmitDisable(void) +{ + U1MODEbits.UTXEN = 0; +} + +void UART1_AutoBaudSet(bool enable) +{ + U1INTbits.ABDIF = 0U; + U1INTbits.ABDIE = enable; + U1MODEbits.ABAUD = enable; +} + +bool UART1_AutoBaudQuery(void) +{ + return U1MODEbits.ABAUD; +} + +bool UART1_AutoBaudEventEnableGet(void) +{ + return U1INTbits.ABDIE; +} + +size_t UART1_ErrorGet(void) +{ + uartError.status = 0; + if(U1STAbits.FERR == 1U) + { + uartError.status = uartError.status|UART_ERROR_FRAMING_MASK; + } + if(U1STAbits.PERR== 1U) + { + uartError.status = uartError.status|UART_ERROR_PARITY_MASK; + } + if(U1STAbits.OERR== 1U) + { + uartError.status = uartError.status|UART_ERROR_RX_OVERRUN_MASK; + U1STAbits.OERR = 0; + } + if(U1STAbits.TXCIF== 1U) + { + uartError.status = uartError.status|UART_ERROR_TX_COLLISION_MASK; + U1STAbits.TXCIF = 0; + } + if(U1STAbits.ABDOVF== 1U) + { + uartError.status = uartError.status|UART_ERROR_AUTOBAUD_OVERFLOW_MASK; + U1STAbits.ABDOVF = 0; + } + + return uartError.status; +} + +void UART1_BRGCountSet(uint32_t brgValue) +{ + U1BRG = brgValue & 0xFFFFU; + U1BRGH = (brgValue >>16U) & 0x000FU; +} + +uint32_t UART1_BRGCountGet(void) +{ + uint32_t brgValue; + + brgValue = U1BRGH; + brgValue = (brgValue << 16U) | U1BRG; + + return brgValue; +} + +void UART1_BaudRateSet(uint32_t baudRate) +{ + uint32_t brgValue; + + if((baudRate >= UART1_MIN_ACHIEVABLE_BAUD_WITH_FRACTIONAL) && (baudRate != 0)) + { + U1MODEHbits.BCLKMOD = 1; + U1MODEbits.BRGH = 0; + brgValue = UART1_BAUD_TO_BRG_WITH_FRACTIONAL(baudRate); + } + else + { + U1MODEHbits.BCLKMOD = 0; + U1MODEbits.BRGH = 1; + brgValue = UART1_BAUD_TO_BRG_WITH_BRGH_1(baudRate); + } + U1BRG = brgValue & 0xFFFFU; + U1BRGH = (brgValue >>16U) & 0x000FU; +} + +uint32_t UART1_BaudRateGet(void) +{ + uint32_t brgValue; + uint32_t baudRate; + + brgValue = UART1_BRGCountGet(); + if((U1MODEHbits.BCLKMOD == 1) && (brgValue != 0)) + { + baudRate = UART1_BRG_TO_BAUD_WITH_FRACTIONAL(brgValue); + } + else if(U1MODEbits.BRGH == 1) + { + baudRate = UART1_BRG_TO_BAUD_WITH_BRGH_1(brgValue); + } + else + { + baudRate = UART1_BRG_TO_BAUD_WITH_BRGH_0(brgValue); + } + return baudRate; +} diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart1.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart1.h new file mode 100644 index 0000000..6ee2c7b --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart1.h @@ -0,0 +1,317 @@ +/** + * UART1 Generated Driver Header File + * + * @file uart1.h + * + * @ingroup uartdriver + * + * @brief This is the generated driver header file for the UART1 driver + * + * @skipline @version Firmware Driver Version 1.7.0 + * + * @skipline @version PLIB Version 1.5.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef UART1_H +#define UART1_H + +// Section: Included Files + +#include +#include +#include +#include "uart_interface.h" + +// Section: Data Type Definitions + +/** + @ingroup uartdriver + @brief Structure object of type UART_INTERFACE with the + custom name given by the user in the Melody Driver User interface. + The default name e.g. UART1 can be changed by the + user in the UART user interface. + This allows defining a structure with application specific name + using the 'Custom Name' field. Application specific name allows the + API Portability. +*/ +extern const struct UART_INTERFACE UART1_Drv; + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Initialize API + */ +#define UART1_Drv_Initialize UART1_Initialize + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Deinitialize API + */ +#define UART1_Drv_Deinitialize UART1_Deinitialize + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Read API + */ +#define UART1_Drv_Read UART1_Read + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_Write API + */ +#define UART1_Drv_Write UART1_Write + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_IsRxReady API + */ +#define UART1_Drv_IsRxReady UART1_IsRxReady + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_IsTxReady API + */ +#define UART1_Drv_IsTxReady UART1_IsTxReady + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_IsTxDone API + */ +#define UART1_Drv_IsTxDone UART1_IsTxDone + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_TransmitEnable API + */ +#define UART1_Drv_TransmitEnable UART1_TransmitEnable + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_TransmitDisable API + */ +#define UART1_Drv_TransmitDisable UART1_TransmitDisable + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_AutoBaudSet API + */ +#define UART1_Drv_AutoBaudSet UART1_AutoBaudSet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_AutoBaudQuery API + */ +#define UART1_Drv_AutoBaudQuery UART1_AutoBaudQuery + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_AutoBaudEventEnableGet API + */ +#define UART1_Drv_AutoBaudEventEnableGet UART1_AutoBaudEventEnableGet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_ErrorGet API + */ +#define UART1_Drv_ErrorGet UART1_ErrorGet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BRGCountSet API + */ +#define UART1_Drv_BRGCountSet UART1_BRGCountSet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BRGCountGet API + */ +#define UART1_Drv_BRGCountGet UART1_BRGCountGet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BaudRateSet API + */ +#define UART1_Drv_BaudRateSet UART1_BaudRateSet + +/** + * @ingroup uartdriver + * @brief This macro defines the Custom Name for \ref UART1_BaudRateGet API + */ +#define UART1_Drv_BaudRateGet UART1_BaudRateGet + +// Section: UART1 Driver Routines + +/** + * @ingroup uartdriver + * @brief Initializes the UART driver + * @param none + * @return none + */ +void UART1_Initialize(void); + +/** + * @ingroup uartdriver + * @brief Deinitializes the UART to POR values + * @param none + * @return none + */ +void UART1_Deinitialize(void); + +/** + * @ingroup uartdriver + * @brief Reads a byte of data from the UART1 + * @pre UART1_Initialize function should have been called + * before calling this function. The transfer status should be checked + * to see if the receiver is not empty before calling this function. + * @param none + * @return A data byte received by the driver + */ +uint8_t UART1_Read(void); + +/** + * @ingroup uartdriver + * @brief Writes a byte of data to the UART1 + * @pre UART1_Initialize function should have been called + * before calling this function. The transfer status should be checked + * to see if transmitter is not full before calling this function. + * @param[in] data - Data byte to write to the UART1 + * @return none + */ +void UART1_Write(uint8_t data); + +/** + * @ingroup uartdriver + * @brief Returns a boolean value if data is available to read + * @param none + * @return true - Data available to read + * @return false - Data not available to read + */ +bool UART1_IsRxReady(void); + +/** + * @ingroup uartdriver + * @brief Returns a boolean value if data can be written + * @param none + * @return true - Data can be written + * @return false - Data can not be written + */ +bool UART1_IsTxReady(void); + +/** + * @ingroup uartdriver + * @brief Indicates if all bytes have been transferred + * @param none + * @return true - All bytes transferred + * @return false - Data transfer is pending + */ +bool UART1_IsTxDone(void); + +/** + * @ingroup uartdriver + * @brief Enables UART1 transmit + * @param none + * @return none + */ +void UART1_TransmitEnable(void); + +/** + * @ingroup uartdriver + * @brief Disables UART1 transmit + * @param none + * @return none + */ +void UART1_TransmitDisable(void); + +/** + * @ingroup uartdriver + * @brief Enables or disables UART1 Auto-Baud detection + * @param[in] enable - true, starts the auto-baud detection + * @param[in] enable - false, disables the auto-baud detection + * @return none + */ +void UART1_AutoBaudSet(bool enable); + +/** + * @ingroup uartdriver + * @brief Returns the status of Auto-Baud detection + * @param none + * @return true - Auto-Baud detection in progress or counter overflow occurred + * @return false - Auto-Baud detection is complete or disabled + */ +bool UART1_AutoBaudQuery(void); + +/** + * @ingroup uartdriver + * @brief Returns enable state of the Auto-Baud feature + * @param none + * @return true - Auto-Baud is enabled + * @return false - Auto-Baud is disabled + */ +bool UART1_AutoBaudEventEnableGet(void); + +/** + * @ingroup uartdriver + * @brief Sets the BRG value of UART1 + * @param[in] baudRate - BRG value upto 20 bits + * @return none + * @note Make sure the is no transmission in progress using \ref UART1_IsTxDone function + */ +void UART1_BRGCountSet(uint32_t brgValue); + +/** + * @ingroup uartdriver + * @brief Gets the BRG value of UART1 + * @param none + * @return Combined BRG value upto 20 bits + */ +uint32_t UART1_BRGCountGet(void); + +/** + * @ingroup uartdriver + * @brief Sets the calculated Baud-Rate of UART1 + * @param[in] baudRate - Value of Baud-Rate to be set + * @return none + * @note Make sure the is no transmission in progress using \ref UART1_IsTxDone function + */ +void UART1_BaudRateSet(uint32_t baudRate); + +/** + * @ingroup uartdriver + * @brief Gets the actual Baud-Rate of UART1 + * @param none + * @return Actual baud-rate of UART1 + */ +uint32_t UART1_BaudRateGet(void); + +/** + * @ingroup uartdriver + * @brief Returns the error status of UART1 + * @param none + * @return Errors with masking as per \ref UART1_ERROR_MASKS + */ +size_t UART1_ErrorGet(void); + +#endif // UART1_H + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart_interface.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart_interface.h new file mode 100644 index 0000000..ef9eb86 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart_interface.h @@ -0,0 +1,127 @@ +/** + * UART Generated Driver Interface Header File + * + * @file uart_interface.h + * + * @defgroup uartdriver UART Driver + * + * @brief Universal Asynchronous Receiver Transmitter driver using dsPIC MCUs + * + * @skipline @version Firmware Driver Version 1.7.0 + * + * @skipline @version PLIB Version 1.5.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef UART_INTERFACE_H +#define UART_INTERFACE_H + +// Section: Included Files + +#include +#include +#include +#include "uart_types.h" + +// Section: Data Type Definitions + +/** + @ingroup uartdriver + @struct UART_INTERFACE + @brief Structure containing the function pointers of UART driver +*/ +struct UART_INTERFACE{ + void (*Initialize)(void); + ///< Pointer to UARTx_Initialize e.g. \ref UART1_Initialize + + void (*Deinitialize)(void); + ///< Pointer to UARTx_Deinitialize e.g. \ref UART1_Deinitialize + + uint8_t (*Read)(void); + ///< Pointer to UARTx_Read e.g. \ref UART1_Read + + void (*Write)(uint8_t); + ///< Pointer to UARTx_Write e.g. \ref UART1_Write + + bool (*IsRxReady)(void); + ///< Pointer to UARTx_IsRxReady e.g. \ref UART1_IsRxReady + + bool (*IsTxReady)(void); + ///< Pointer to UARTx_IsTxReady e.g. \ref UART1_IsTxReady + + bool (*IsTxDone)(void); + ///< Pointer to UARTx_IsTxDone e.g. \ref UART1_IsTxDone + + void (*TransmitEnable)(void); + ///< Pointer to UARTx_TransmitEnable e.g. \ref UART1_TransmitEnable + + void (*TransmitDisable)(void); + ///< Pointer to UARTx_TransmitDisable e.g. \ref UART1_TransmitDisable + + void (*TransmitInterruptEnable)(void); + ///< Pointer to UARTx_TransmitInterruptEnable e.g. \ref UART1_TransmitInterruptEnable + + void (*TransmitInterruptDisable)(void); + ///< Pointer to UARTx_TransmitInterruptDisable e.g. \ref UART1_TransmitInterruptDisable + + void (*AutoBaudSet)(bool enable); + ///< Pointer to UARTx_AutoBaudSet e.g. \ref UART1_AutoBaudSet + + bool (*AutoBaudQuery)(void); + ///< Pointer to UARTx_AutoBaudQuery e.g. \ref UART1_AutoBaudQuery + + bool (*AutoBaudEventEnableGet)(void); + ///< Pointer to UARTx_AutoBaudEventEnableGet e.g. \ref UART1_AutoBaudEventEnableGet + + void (*BRGCountSet)(uint32_t brgValue); + ///< Pointer to UARTx_BRGCountSet e.g. \ref UART1_BRGCountSet + + uint32_t (*BRGCountGet)(void); + ///< Pointer to UARTx_BRGCOuntGet e.g. \ref UART1_BRGCountGet + + void (*BaudRateSet)(uint32_t baudRate); + ///< Pointer to UARTx_BaudRateSet e.g. \ref UART1_BaudRateSet + + uint32_t (*BaudRateGet)(void); + ///< Pointer to UARTx_BaudRateGet e.g. \ref UART1_BaudRateGet + + size_t (*ErrorGet)(void); + ///< Pointer to UARTx_ErrorGet e.g. \ref UART1_ErrorGet + + void (*RxCompleteCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_RxCompleteCallbackRegister e.g. \ref UART1_RxCompleteCallbackRegister (defined only in interrupt mode) + void (*TxCompleteCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_TxCompleteCallbackRegister e.g. \ref UART1_TxCompleteCallbackRegister (defined only in interrupt mode) + void (*TxCollisionCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_TxCollisionCallbackRegister e.g. \ref UART1_TxCollisionCallbackRegister (defined only in interrupt mode) + void (*FramingErrorCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_FramingErrorCallbackRegister e.g. \ref UART1_FramingErrorCallbackRegister (defined only in interrupt mode) + void (*OverrunErrorCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_OverrunErrorCallbackRegister e.g. \ref UART1_OverrunErrorCallbackRegister (defined only in interrupt mode) + void (*ParityErrorCallbackRegister)(void (*CallbackHandler)(void)); + ///< Pointer to UARTx_ParityErrorCallbackRegister e.g. \ref UART1_ParityErrorCallbackRegister (defined only in interrupt mode) +}; +#endif + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart_types.h b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart_types.h new file mode 100644 index 0000000..079d35c --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/mcc_generated_files/uart/uart_types.h @@ -0,0 +1,57 @@ +/** + * UART Generated Driver Types Header File + * + * @file uart_types.h + * + * @ingroup uartdriver + * + * @brief This is the generated driver types header file for the UART driver + * + * @skipline @version Firmware Driver Version 1.7.0 + * + * @skipline @version PLIB Version 1.5.0 + * + * @skipline Device : dsPIC33CK256MP508 +*/ + +/* +© [2023] Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip + software and any derivatives exclusively with Microchip products. + You are responsible for complying with 3rd party license terms + applicable to your use of 3rd party software (including open source + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR + THIS SOFTWARE. +*/ + +#ifndef UART_TYPES_H +#define UART_TYPES_H + +/** + @ingroup uartdriver + @enum UART_ERROR + @brief This Enum can be used to know UART error type + using UARTx_ErrorGet function e.g. \ref UART1_ErrorGet. +*/ +enum UART_ERROR_MASKS{ + UART_ERROR_FRAMING_MASK = 0x1, + UART_ERROR_PARITY_MASK = 0x2, + UART_ERROR_RX_OVERRUN_MASK = 0x4, + UART_ERROR_TX_COLLISION_MASK = 0x8, + UART_ERROR_AUTOBAUD_OVERFLOW_MASK = 0x10, +}; + +#endif + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/nbproject/configurations.xml b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/nbproject/configurations.xml new file mode 100644 index 0000000..bc252c6 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/nbproject/configurations.xml @@ -0,0 +1,482 @@ + + + + + + + mcc_generated_files/dee/dee_dual_panel.h + mcc_generated_files/dee/dee_types.h + mcc_generated_files/dee/dee.h + + + mcc_generated_files/flash/flash_nonblocking.h + mcc_generated_files/flash/flash_interface.h + mcc_generated_files/flash/flash_hardware_nonblocking.h + mcc_generated_files/flash/flash_types.h + + + mcc_generated_files/system/clock.h + mcc_generated_files/system/dmt.h + mcc_generated_files/system/reset_types.h + mcc_generated_files/system/traps.h + mcc_generated_files/system/watchdog.h + mcc_generated_files/system/pins.h + mcc_generated_files/system/interrupt.h + mcc_generated_files/system/system.h + mcc_generated_files/system/interrupt_types.h + mcc_generated_files/system/system_types.h + mcc_generated_files/system/reset.h + + + mcc_generated_files/uart/uart1.h + mcc_generated_files/uart/uart_interface.h + mcc_generated_files/uart/uart_types.h + + + + + + + + + + mcc_generated_files/dee/src/dee_dual_panel.c + mcc_generated_files/dee/src/dee.c + + + + + mcc_generated_files/flash/src/flash_nonblocking.c + mcc_generated_files/flash/src/flash_asm_nonblocking.s + + + + + mcc_generated_files/system/src/config_bits.c + mcc_generated_files/system/src/traps.c + mcc_generated_files/system/src/dmt.c + mcc_generated_files/system/src/dmt_asm.s + mcc_generated_files/system/src/system.c + mcc_generated_files/system/src/clock.c + mcc_generated_files/system/src/pins.c + mcc_generated_files/system/src/interrupt.c + mcc_generated_files/system/src/reset.c + + + + + mcc_generated_files/uart/src/uart1.c + + + + main.c + + + Makefile + dee-dual-panel-demo-partition2.mc3 + + + Makefile + + + + localhost + dsPIC33CK256MP508 + + + pk4hybrid + XC16 + 2.10 + 3 + + + + + + + + + + + + + + + false + false + + + + + + + false + false + + false + + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/nbproject/project.xml b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/nbproject/project.xml new file mode 100644 index 0000000..e2c4b13 --- /dev/null +++ b/dspic33ck-curiosity-dual-panel-dee-demo/dee-dual-panel-demo-partition2.X/nbproject/project.xml @@ -0,0 +1,23 @@ + + + com.microchip.mplab.nbide.embedded.makeproject + + + dee-dual-panel-demo-partition2 + d3d39502-7e96-4414-83d5-147c1098044e + 0 + ISO-8859-1 + + + + + default + 2 + + + + false + + + + diff --git a/images/partition1.jpg b/images/partition1.jpg new file mode 100644 index 0000000..1b67a06 Binary files /dev/null and b/images/partition1.jpg differ diff --git a/images/partition2.jpg b/images/partition2.jpg new file mode 100644 index 0000000..c161ac6 Binary files /dev/null and b/images/partition2.jpg differ diff --git a/images/projectConfig.jpg b/images/projectConfig.jpg new file mode 100644 index 0000000..d328c21 Binary files /dev/null and b/images/projectConfig.jpg differ