-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19a4c5e
commit 7407c12
Showing
16 changed files
with
1,188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [v1.0](https://github.com/sigfox-tech-radio/sigfox-ep-example-holtek-bc68f2150/releases/tag/v1.0) - 02 Jun 2023 | ||
|
||
### General | ||
|
||
* First version of the Holtek BC68F2150 Sigfox example code. | ||
|
||
### Known limitations | ||
|
||
* Depending on the Holtek IDE version, some execution issues can appear on some specific conditions (full memory usage and/or call depth). Please consider using **HT-IDE3000 V8.1.4** or above. | ||
* Due to the limited memory size (especially RAM) the full featured library cannot be embedded on the SoC. Use the **optimization flags** according to targetted the application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Sigfox End-Point library implementation example on Holtek BC68F2150 | ||
|
||
## Description | ||
|
||
This repository shows an example of Sigfox End-Point Library integraton on a HOLTEK low cost transmiter with flash MCU. It uses the code optimization features of the EP-LIB in order to minimize the memory footprint inside the MCU. | ||
|
||
## Architecture | ||
|
||
This repository contains several source code and project files needed to compile the project. Only the source code files of the EP_LIB are not be included inside this repository: the EP_LIB project is a submodule and must be updated before to upload sources files in `middleware/sigfox/sigfox-ep-lib` folder. | ||
|
||
``` | ||
. # Root directory | ||
├── middleware # Middleware | ||
│ ├── sigfox # Sigfox middleware subdirectory | ||
│ │ ├── sigfox-ep-lib # EP_LIB submodule | ||
│ │ │ └── ... | ||
│ │ ├── manuf # EP_LIB manufacturer API specific to this SoC | ||
│ │ │ └── mcu_api.c | ||
│ │ │ └── rf_api.c | ||
│ │ │ └── mcu_rf_api_rodata.c | ||
│ │ │ └── mcu_rf_api_rodata.h | ||
│ │ │ └── TI_aes_128_encr_only.c | ||
│ │ │ └── TI_aes_128_encr_only.h | ||
├── driver # Drivers | ||
│ │ ├── src # Driver header subdirectory | ||
│ │ │ └── iap.h | ||
│ │ ├── src # Driver source subdirectory | ||
│ │ │ └── iap.c | ||
├── output # Output generation folder, containing all generated files by IDE | ||
│ ├── *.OBJ | ||
│ ├── *.ASM | ||
│ ├── *.LST | ||
│ └── *... | ||
├── main.c # Application source file | ||
├── lcd.opt # Project option file | ||
├── lcd.pjt # Project file | ||
├── lcd.pjtx # Project file | ||
└── README.md | ||
``` | ||
|
||
## Hardware | ||
|
||
The following figure shows the hardware architecture of the Holtek BC68F2150 board. | ||
|
||
<p align="center"> | ||
<img src="docs/images/holtek_bc68f2150_architecture.png" width="600"/> | ||
</p> | ||
|
||
## Getting Started | ||
|
||
### Cloning the repository and submodule | ||
|
||
```bash | ||
$ git clone https://github.com/sigfox-tech-radio/sigfox-ep-example-holtek-bc68f2150.git | ||
$ git submodule init | ||
$ git submodule update | ||
``` | ||
|
||
### How to build project | ||
|
||
- Download the HT-IDE3000 software from Holtek web site. | ||
- Click on pjtx project file to run IDE. Now you are ready to compile and update the source code for your application. *For more information on the IDE, compiler, etc... please refer to pdf files available in DOC IDE folder.* | ||
- To configure the EP_LIB flags: right-click on the project > Project Settings > Project Option > Define Symbol. | ||
|
||
### How to program and debug | ||
|
||
- To flash or debug the device you need to buy a *e-link* programmer from HOLTEK | ||
- Connect the device to the programmer and click on the Build/Rebuild button, the flash process will be launched automatically. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/*!***************************************************************** | ||
* \file iap.h | ||
* \brief In Application Programming driver. | ||
******************************************************************* | ||
* \copyright | ||
* | ||
* Copyright (c) 2022, UnaBiz SAS | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1 Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2 Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3 Neither the name of UnaBiz SAS nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY | ||
* THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
*******************************************************************/ | ||
|
||
#ifndef __IAP_H__ | ||
#define __IAP_H__ | ||
|
||
/*** IAP structures ***/ | ||
|
||
/*!****************************************************************** | ||
* \enum IAP_status_t | ||
* \brief In Application Programming error codes. | ||
*******************************************************************/ | ||
typedef enum { | ||
IAP_SUCCESS = 0, | ||
IAP_ERROR = 1, | ||
} IAP_status_t; | ||
|
||
/*!****************************************************************** | ||
* \fn IAP_status_t IAP_ew_en_proc(void) | ||
* \brief In Application Programming erase write enable procedure. | ||
* \param[in] none | ||
* \param[out] none | ||
* \retval Function execution status. | ||
*******************************************************************/ | ||
IAP_status_t IAP_ew_en_proc(void); | ||
|
||
/*!****************************************************************** | ||
* \fn IAP_status_t IAP_read(unsigned short add, unsigned short *flash_word, unsigned char len) | ||
* \brief In Application Programming read procedure. | ||
* \param[in] add:Address to read data | ||
* \param[out] *flash_word:Reading data pointer | ||
* \param[in] len:Size to read | ||
* \retval Function execution status. | ||
*******************************************************************/ | ||
IAP_status_t IAP_read(unsigned short add, unsigned short *flash_word, unsigned char len); | ||
|
||
/*!****************************************************************** | ||
* \fn IAP_status_t IAP_write(unsigned short add, unsigned short *flash_word, unsigned char len, char erase_before) | ||
* \brief In Application Programming write procedure(warning the IAP drivers support only write data bloc of 4 word or 8 bytes). | ||
* \param[in] add:Address to write data | ||
* \param[out] *flash_word:Writing data pointer | ||
* \param[in] len:Size to write | ||
* \param[in] erase_before:Erase page or not before | ||
* \retval Function execution status. | ||
*******************************************************************/ | ||
IAP_status_t IAP_write(unsigned short add, unsigned short *flash_word, unsigned char len, char erase_before); | ||
|
||
#endif /* __IAP_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/*!***************************************************************** | ||
* \file iap.c | ||
* \brief In Application Programming driver. | ||
******************************************************************* | ||
* \copyright | ||
* | ||
* Copyright (c) 2022, UnaBiz SAS | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1 Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2 Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* 3 Neither the name of UnaBiz SAS nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY | ||
* THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | ||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
*******************************************************************/ | ||
|
||
#include "iap.h" | ||
#include "BC68F2150.h" | ||
|
||
IAP_status_t IAP_ew_en_proc(void) { | ||
_fmod0 = 0; | ||
_fmod1 = 1; | ||
_fmod2 = 1; | ||
_fwpen = 1; | ||
_fd1l = 0x00; | ||
_fd1h = 0x04; | ||
_fd2l = 0x0d; | ||
_fd2h = 0x09; | ||
_fd3l = 0xc3; | ||
_fd3h = 0x40; | ||
while (_fwpen) | ||
GCC_CLRWDT(); | ||
if (_cfwen == 0) | ||
return IAP_ERROR; | ||
else | ||
return IAP_SUCCESS; | ||
} | ||
IAP_status_t IAP_read(unsigned short add, unsigned short *flash_word, unsigned char len) { | ||
//Configure to read program memory and set flash memory read enable bit | ||
_fc0 &= 0b10001101; | ||
_fc0 |= 0b00110010; | ||
while(len != 0) { | ||
//Set address to read | ||
_farh = (add >> 8) & 0x1F; | ||
_farl = (add) & 0xFF; | ||
_frd = 1; | ||
//Wait read process completed | ||
while (_frd) | ||
GCC_CLRWDT(); | ||
//Read lower byte | ||
*flash_word = (_fd0l & 0x00FF); | ||
//Read upper byte | ||
*flash_word |= ((_fd0h << 8) & 0xFF00); | ||
flash_word++; | ||
len --; | ||
//Incr address to next 2 or 1 bytes | ||
add += 1; | ||
}; | ||
//Clear read enable bit | ||
_frden = 0; | ||
return IAP_SUCCESS; | ||
} | ||
|
||
IAP_status_t IAP_write(unsigned short add, unsigned short *flash_word, unsigned char len, char erase_before) { | ||
|
||
if (IAP_ew_en_proc() != IAP_SUCCESS) | ||
return IAP_ERROR; | ||
|
||
if (erase_before) { | ||
//Erase Block | ||
_farh = (add >> 8) & 0x1F; | ||
_farl = (add) & 0xFF; | ||
_fmod0 = 1; | ||
_fmod1 = 0; | ||
_fmod2 = 0; | ||
_fwt = 1; | ||
while (_fwt != 0); | ||
} | ||
|
||
while(len != 0) { | ||
_fmod0 = 0; | ||
_fmod1 = 0; | ||
_fmod2 = 0; | ||
_fd0l = 0xFF; | ||
_fd0h = 0xFF; | ||
_fd1l = 0xFF; | ||
_fd1h = 0xFF; | ||
_fd2l = 0xFF; | ||
_fd2h = 0xFF; | ||
_fd3l = 0xFF; | ||
_fd3h = 0xFF; | ||
|
||
_fd0l = (*flash_word) & 0xFF; | ||
_fd0h = (*flash_word >> 8) & 0xFF; | ||
flash_word++; | ||
len--; | ||
if (len == 0) { | ||
_fwt = 1; | ||
while (_fwt != 0); | ||
continue; | ||
} | ||
_fd1l = (*flash_word) & 0xFF; | ||
_fd1h = (*flash_word >> 8) & 0xFF; | ||
flash_word++; | ||
len--; | ||
if (len == 0) { | ||
_fwt = 1; | ||
while (_fwt != 0); | ||
continue; | ||
} | ||
_fd2l = (*flash_word) & 0xFF; | ||
_fd2h = (*flash_word >> 8) & 0xFF; | ||
flash_word++; | ||
len--; | ||
if (len == 0) { | ||
_fwt = 1; | ||
while (_fwt != 0); | ||
continue; | ||
} | ||
_fd3l = (*flash_word) & 0xFF; | ||
_fd3h = (*flash_word >> 8) & 0xFF; | ||
flash_word++; | ||
len--; | ||
_fwt = 1; | ||
while (_fwt != 0); | ||
} | ||
_cfwen = 0; | ||
return IAP_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<HTIDE><CHTIdeProject g_wProjectVersion="20" m_sProjectDirectory="Z:\tmp\lcd" m_sProjectName="lcd" m_bDefault="0" m_sOutputDir=".\output\" m_sTargetChip="BC68F2150" m_nBuildMode="0" m_bListFile="1" m_bGenDisassembly="1" m_bMapFile="1" m_bStandAlone="0" m_bCodFile="0" m_bUseBootLoader="0" m_nBootLoaderMode="0" m_bOtpFile="1" m_bEnterDebugModeAfterBuild="1" m_dwOID="15598078" m_nSteppingCmd="0" m_wFIFOSize="0" m_byteBLID="0" m_strUserBCLPath="" m_bUseHoltekID="1" m_wCustomVID="0" m_wCustomPID="0" m_nEmulatedISPType="-1" m_CompilerFlagString=" -Wall -Os -fshort-enums" m_LinkFlagString="/OptimizeParam=16 /compact_rom /Stack /LInsVarOpt" m_AssemblerFlagString="" m_bCustomUsage="0" m_wUsagePage="65280" m_wUsage="32" m_bPartialLock="0" m_strPartialLockLib="" m_bIdCode_CheckBox="0" m_sIdCode_Edit="" m_strEntryFun="" m_bParseEntryFun="0" m_strGUID="" m_bCodeConfig="0" m_bTraceFields0="0" m_bTraceFields1="0" m_bTraceFields2="1" m_bTraceFields3="0" m_bTraceFields4="0" m_bTraceFields5="0" m_bTraceFields6="0" m_bTraceFields7="0" m_bTraceFields8="0" m_bTraceFields9="0" m_bDisplayVariableValue="1" m_nCrossToolVendor="3" m_bDisplayHexValue="0" m_bDisplayHexValueReg="0" m_bDetectStackOverflow="1" m_bDownLoadEEPROM="0" m_bRunToMainAfterBuild="1" m_CurLibType="8"><CBreakpoint m_nOCDSBreak="105" Count="0"/><m_listOfLib Count="0"/><m_SystemLibArr Count="2"><_0 Value="LIBHOLTEKGCC.LIB" StartAddr="-1" EndAddr="-1"/><_1 Value="v3_lmrsc.lib" StartAddr="-1" EndAddr="-1"/></m_SystemLibArr><m_listOfSecAddr Count="0"/><m_listOfSources Count="12"><_0 Value=".\startup1_l.asm" Attribute="0" StartAddr="-1" EndAddr="-1"/><_1 Value=".\main.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_2 Value=".\middleware\sigfox\manuf\mcu_api.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_3 Value=".\middleware\sigfox\manuf\mcu_rf_api_rodata.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_4 Value=".\middleware\sigfox\manuf\rf_api.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_5 Value=".\middleware\sigfox\manuf\TI_aes_128_encr_only.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_6 Value=".\middleware\sigfox\sigfox-ep-lib\src\sigfox_ep_api.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_7 Value=".\middleware\sigfox\sigfox-ep-lib\src\sigfox_error.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_8 Value=".\middleware\sigfox\sigfox-ep-lib\src\core\sigfox_crc.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_9 Value=".\middleware\sigfox\sigfox-ep-lib\src\core\sigfox_ep_bitstream.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_10 Value=".\middleware\sigfox\sigfox-ep-lib\src\core\sigfox_ep_frequency.c" Attribute="0" StartAddr="-1" EndAddr="-1"/><_11 Value=".\drivers\src\iap.c" Attribute="0" StartAddr="-1" EndAddr="-1"/></m_listOfSources><m_listOfSymDef Count="9"><_0 Value="__V3__"/><_1 Value="Disable_Bit_Initial"/><_2 Value="RC1"/><_3 Value="APPLICATION_MESSAGES"/><_4 Value="UL_BIT_RATE_BPS=100"/><_5 Value="TX_POWER_DBM_EIRP=13"/><_6 Value="T_IFU_MS=500"/><_7 Value="UL_PAYLOAD_SIZE=1"/><_8 Value="MESSAGE_COUNTER_ROLLOVER=4096"/></m_listOfSymDef><m_DocBook Count="0"/><m_PrjFolder Count="0"/><m_RamMonList Count="4"><_0 AddrFrom="-1" AddrTo="-1" bEnable="0"/><_1 AddrFrom="-1" AddrTo="-1" bEnable="0"/><_2 AddrFrom="-1" AddrTo="-1" bEnable="0"/><_3 AddrFrom="-1" AddrTo="-1" bEnable="0"/></m_RamMonList><CWatchVarList Count="4"><_0 Key="Watch1"><_0 Count="0"/></_0><_1 Key="Watch2"><_1 Count="0"/></_1><_2 Key="Watch3"><_2 Count="0"/></_2><_3 Key="Watch4"><_3 Count="0"/></_3></CWatchVarList><CWorkSpace m_uSchemaVersion="0"><m_listOfChildState Count="2"><_0><CFrameState m_sName="HTIDE8" m_sPath=".\main.c" m_uSchemaVersion="0" m_Cursor_x="0" m_Cursor_y="31" m_Scroll_x="0" m_Scroll_y="0"><m_wndpl flags="0" length="44" ptMaxPositionX="-4" ptMaxPositionY="-23" ptMinPositionX="-1" ptMinPositionY="-1" rcNormalPositionLeft="44" rcNormalPositionTop="44" rcNormalPositionRight="608" rcNormalPositionBottom="538" showCmd="3"/></CFrameState></_0><_1><CFrameState m_sName="HTIDE8" m_sPath=".\middleware\sigfox\manuf\rf_api.c" m_uSchemaVersion="0" m_Cursor_x="0" m_Cursor_y="45" m_Scroll_x="0" m_Scroll_y="12"><m_wndpl flags="0" length="44" ptMaxPositionX="-4" ptMaxPositionY="-23" ptMinPositionX="-1" ptMinPositionY="-1" rcNormalPositionLeft="132" rcNormalPositionTop="132" rcNormalPositionRight="696" rcNormalPositionBottom="604" showCmd="1"/></CFrameState></_1></m_listOfChildState><m_wndplMainFrame flags="0" length="44" ptMaxPositionX="-3777" ptMaxPositionY="5" ptMinPositionX="-1" ptMinPositionY="-1" rcNormalPositionLeft="-3313" rcNormalPositionTop="31" rcNormalPositionRight="-1916" rcNormalPositionBottom="1084" showCmd="3"/></CWorkSpace><m_listIncludeDir Count="3"><_0 Value="*"/><_1 Value="middleware\sigfox\sigfox-ep-lib\inc"/><_2 Value="drivers\inc"/></m_listIncludeDir><m_listLibDir Count="1"><_0 Value="*"/></m_listLibDir><CBookMarkList Count="0"/><m_listRamMonVar Count="0"/></CHTIdeProject></HTIDE> |
Oops, something went wrong.