Skip to content

Commit

Permalink
Merge pull request Infineon#270 from LinjingZhang/xmc1400_can
Browse files Browse the repository at this point in the history
XMC Arduino CAN Lib (Receiving)
  • Loading branch information
ederjc authored Mar 27, 2024
2 parents 08f3b1a + f5f9923 commit ba6afd4
Show file tree
Hide file tree
Showing 36 changed files with 5,116 additions and 55 deletions.
30 changes: 19 additions & 11 deletions .github/scripts/release.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import argparse, copy, hashlib, json, re, requests, os, shutil

version = '0.1.1'
version = '0.2.0'

xmc_ino_root_path = os.path.relpath(os.path.join(os.path.join(os.getcwd(), os.pardir), os.pardir))
build_dir_name = 'pkg_build'
Expand Down Expand Up @@ -66,19 +66,20 @@ def get_local_package_index_json():
return data

def get_platform_data_struct_copy(pkg_index):
return copy.deepcopy(pkg_index['packages'][0]['platforms'][0])
return copy.deepcopy(pkg_index['packages'][0]['platforms'])

def set_new_platform_data_fields(platform_data, pkg_name, version, repository):
def set_new_platform_data_fields(platform_data_index, pkg_name, version, repository):
semver = strip_prefix_from_version(version)
platform_data = platform_data_index['packages'][0]['platforms'][0]
platform_data['version'] = str(semver)
archive_file_name = str(pkg_name) + ".zip"
platform_data['archiveFileName'] = archive_file_name
platform_data['url'] = "https://github.com/" + str(repository) + "/releases/download/" + str(version) + "/" + str(archive_file_name)
platform_data['checksum'] ="SHA-256:" + str(get_package_sha256(os.path.join(pkg_assets_build_path, archive_file_name)))
platform_data['size'] = str(get_package_size(os.path.join(pkg_assets_build_path, archive_file_name)))

def add_new_platform_to_package_index(pkg_index, new_platform):
pkg_index['packages'][0]['platforms'].insert(0, new_platform)
def add_platform_to_package_index(pkg_index, platform):
pkg_index['packages'][0]['platforms'].insert(1, platform)

def make_package_index_file(pkg_index):
pkg_index_json_obj = json.dumps(pkg_index, indent=2)
Expand All @@ -87,14 +88,21 @@ def make_package_index_file(pkg_index):
pkg_file.write(pkg_index_json_obj)

def build_package_index_json(pkg_name, version, repository):
latest_package_index = get_latest_package_index_json() # get online package index json
package_index = get_local_package_index_json() # append local package index template
new_platform_data = get_platform_data_struct_copy(package_index)
set_new_platform_data_fields(new_platform_data, pkg_name, version, repository)
add_new_platform_to_package_index(latest_package_index, new_platform_data)
make_package_index_file(latest_package_index)
# get online package index json
latest_package_index = get_latest_package_index_json()
# get local package index template
local_package_index = get_local_package_index_json()
# set data field in local template for newest package
set_new_platform_data_fields(local_package_index, pkg_name, version, repository)
# get old package array
old_platform_data = get_platform_data_struct_copy(latest_package_index)
# append to local package index
add_platform_to_package_index(local_package_index, old_platform_data)
make_package_index_file(local_package_index)

def build_release_assets(version, repository):
if os.path.exists(pkg_assets_build_path):
os.system("rm -rf "+pkg_assets_build_path)
os.mkdir(pkg_assets_build_path)
pkg_name = mkdir_package_dir(version)
build_package(pkg_name)
Expand Down
22 changes: 21 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,24 @@ Currently github workflow is used for automaticaly build test and release. Workf
To merge your PR, please try to add a git tag in the format `VX.Y.Z` (e.g. V3.3.0) to trigger the release process in your fork and pass the compilation tests.

### WIKI
Because of the limitations of the github wiki, it is difficult to create PR for changes of wiki. Please refer to the answer under: https://stackoverflow.com/questions/10642928/how-can-i-make-a-pull-request-for-a-wiki-page-on-github and create a ticket for your modifications.
Because of the limitations of the github wiki, it is difficult to create PR for changes of wiki. Please refer to the answer under: https://stackoverflow.com/questions/10642928/how-can-i-make-a-pull-request-for-a-wiki-page-on-github and create a ticket for your modifications.

### Debug
New Arduino IDE(v2.3.1) support debug.
Add debug_custom.json file in your sketch folder. Find more information in https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup.
Example using XMC1100:

```
{
"servertype": "jlink",
"device": "XMC1100-0064",
"interface": "SWD",
"serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL"
}
```

If you encounter strange behavior with Arduino IDE, try cleaning up the cache

windows: `C:\User\"username"\AppData\Roaming\arduino-ide`
linux: `~/.config/arduino-ide`
macos: `~/Library/Application Support/arduino-ide/`
32 changes: 29 additions & 3 deletions cores/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern "C" {
#include <xmc_spi.h>
#include <xmc_i2c.h>
#include <xmc_i2s.h>
#include <xmc_can.h>

//****************************************************************************
// @Defines
Expand Down Expand Up @@ -247,9 +248,31 @@ extern "C" {
#endif
} XMC_I2S_t;

//****************************************************************************
// @Imported Global Variables
//****************************************************************************
#ifdef CAN_xmc
/*
* XMC (Arduino) CAN type
*/

typedef struct
{
CAN_NODE_TypeDef *can_node;
uint32_t can_frequency;
XMC_PORT_PIN_t rx;
XMC_GPIO_CONFIG_t rx_config;
XMC_PORT_PIN_t tx;
XMC_GPIO_CONFIG_t tx_config;
XMC_CAN_NODE_RECEIVE_INPUT_t node_input;
IRQn_Type irq_num;
uint32_t irq_service_request;
#if (UC_SERIES == XMC14)
XMC_SCU_IRQCTRL_t protocol_irq_source;
#endif
} XMC_ARD_CAN_t;
#endif

//****************************************************************************
// @Imported Global Variables
//****************************************************************************
extern const XMC_PORT_PIN_t mapping_port_pin[];
extern const XMC_PIN_INTERRUPT_t mapping_interrupt[];
extern const uint8_t mapping_pin_PWM4[][ 2 ];
Expand Down Expand Up @@ -277,6 +300,9 @@ extern "C" {

extern XMC_I2S_t i2s_config;

#ifdef CAN_xmc
extern XMC_ARD_CAN_t XMC_CAN_0;
#endif
//****************************************************************************
// @Prototypes Of Global Functions
//****************************************************************************
Expand Down
38 changes: 19 additions & 19 deletions cores/xmc_lib/XMCLib/inc/xmc1_scu.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
#define XMC_SCU_INTERRUPT_EVENT_TSE_DONE SCU_INTERRUPT_SRMSK_TSE_DONE_Msk /**< Temperature measurement Completion event. */
#define XMC_SCU_INTERRUPT_EVENT_TSE_HIGH SCU_INTERRUPT_SRMSK_TSE_HIGH_Msk /**< Temperature too high event. */
#define XMC_SCU_INTERRUPT_EVENT_TSE_LOW SCU_INTERRUPT_SRMSK_TSE_LOW_Msk /**< Temperature too low event. */
#if defined(CAN)
#if defined(CAN_xmc)
#define XMC_SCU_INTERRUPT_EVENT_PEMCAN (((int64_t)SCU_INTERRUPT_SRMSK1_PEMCI_Msk) << 32U) /**< MultiCAN SRAM Parity Error Event. */
#endif
#if (UC_SERIES == XMC14) || defined(DOXYGEN)
Expand All @@ -148,7 +148,7 @@
/*
* These are the flags which may be passed to XMC_SCU_SetBMI().
*/
#if defined(CAN) || defined(DOXYGEN)
#if defined(CAN_xmc) || defined(DOXYGEN)
#define XMC_SCU_BMI_HWCFG_CAN_BSL (0x0080U) /**< CAN Bootstrap Loader Start-up Mode */
#define XMC_SCU_BMI_HWCFG_CAN_BSLTO (0x0090U) /**< CAN Bootstrap Loader Start-up Mode with time-out */
#define XMC_SCU_BMI_HWCFG_SBSL_CANOPEN (0x00A0U) /**< Secure Bootstrap Loader Start-up Mode over CANopen */
Expand All @@ -169,7 +169,7 @@
#define XMC_SCU_BMI_DAPDIS_CHANNEL_0 (0U << 9) /**< SWD/SPD_0 pin is selected */
#define XMC_SCU_BMI_DAPDIS_CHANNEL_1 (1U << 9) /**< SWD/SPD_1 pin is selected */

#if defined(CAN) || defined(DOXYGEN)
#if defined(CAN_xmc) || defined(DOXYGEN)
#define XMC_SCU_BMI_CANCLK_DCO1 (0U << 11) /**< Synchronous CAN clock via internal oscillator (DCO1) with enabled trimming via external reference is selected */
#define XMC_SCU_BMI_CANCLK_OSCHP (1U << 11) /**< Synchronous CAN clock via external oscillator (OSC_HP) is selected */
#endif
Expand Down Expand Up @@ -349,7 +349,7 @@ typedef enum XMC_SCU_PERIPHERAL_CLOCK
#if defined(POSIF1)
XMC_SCU_PERIPHERAL_CLOCK_POSIF1 = SCU_CLK_CGATSTAT0_POSIF1_Msk, /**< POSIF0 peripheral clock gate. */
#endif
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_PERIPHERAL_CLOCK_MCAN = SCU_CLK_CGATSTAT0_MCAN0_Msk, /**< POSIF0 peripheral clock gate. */
#endif
} XMC_SCU_PERIPHERAL_CLOCK_t;
Expand Down Expand Up @@ -382,68 +382,68 @@ typedef enum XMC_SCU_CCU_TRIGGER
typedef enum XMC_SCU_IRQCTRL
{
XMC_SCU_IRQCTRL_SCU_SR0_IRQ0 = (0U << 8U) | 0U, /**< SCU_SR0 connected to IRQ0 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR0_IRQ0 = (0U << 8U) | 1U, /**< CAN0_SR0 connected to IRQ0 */
#endif
XMC_SCU_IRQCTRL_CCU40_SR0_IRQ0 = (0U << 8U) | 2U, /**< CCU40_SR0 connected to IRQ0 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_SCU_SR0_OR_CAN0_SR0_IRQ0 = (0U << 8U) | 3U, /**< SCU_SR0 and CAN_SR0 are both connected to IRQ0*/
#endif

XMC_SCU_IRQCTRL_SCU_SR1_IRQ1 = (1U << 8U) | 0U, /**< SCU_SR1 connected to IRQ1 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR1_IRQ1 = (1U << 8U) | 1U, /**< CAN0_SR1 connected to IRQ1 */
#endif
#if defined(CCU80)
XMC_SCU_IRQCTRL_CCU80_SR0_IRQ1 = (1U << 8U) | 2U, /**< CCU80_SR0 connected to IRQ1 */
#endif
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_SCU_SR1_OR_CAN0_SR1_IRQ1 = (1U << 8U) | 3U, /**< SCU_SR1 and CAN0_SR1 connected to IRQ1 */
#endif

XMC_SCU_IRQCTRL_SCU_SR2_IRQ2 = (2U << 8U) | 0U, /**< SCU_SR2 connected to IRQ2 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR2_IRQ2 = (2U << 8U) | 1U, /**< CAN0_SR2 connected to IRQ2 */
#endif
#if defined(CCU80)
XMC_SCU_IRQCTRL_CCU80_SR1_IRQ2 = (2U << 8U) | 2U, /**< CCU80_SR1 connected to IRQ2 */
#endif
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_SCU_SR2_OR_CAN0_SR2_IRQ2 = (2U << 8U) | 3U, /**< SCU_SR2 and CAN0_SR2 connected to IRQ2 */
#endif

XMC_SCU_IRQCTRL_ERU0_SR0_IRQ3 = (3U << 8U) | 0U, /**< ERU0_SR0 connected to IRQ3 */
XMC_SCU_IRQCTRL_ERU1_SR0_IRQ3 = (3U << 8U) | 1U, /**< ERU1_SR0 connected to IRQ3 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR0_IRQ3 = (3U << 8U) | 2U, /**< CAN0_SR0 connected to IRQ3 */
#endif
XMC_SCU_IRQCTRL_ERU0_SR0_OR_ERU1_SR0_IRQ3 = (3U << 8U) | 3U, /**< ERU0_SR0 and ERU1_SR0 connected to IRQ3 */

XMC_SCU_IRQCTRL_ERU0_SR1_IRQ4 = (4U << 8U) | 0U, /**< ERU0_SR1 connected to IRQ4 */
XMC_SCU_IRQCTRL_ERU1_SR1_IRQ4 = (4U << 8U) | 1U, /**< ERU1_SR1 connected to IRQ4 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR1_IRQ4 = (4U << 8U) | 2U, /**< CAN0_SR1 connected to IRQ4 */
#endif
XMC_SCU_IRQCTRL_ERU0_SR1_OR_ERU1_SR1_IRQ4 = (4U << 8U) | 3U, /**< ERU0_SR1 and ERU1_SR1 connected to IRQ4 */

XMC_SCU_IRQCTRL_ERU0_SR2_IRQ5 = (5U << 8U) | 0U, /**< ERU0_SR2 connected to IRQ5 */
XMC_SCU_IRQCTRL_ERU1_SR2_IRQ5 = (5U << 8U) | 1U, /**< ERU1_SR2 connected to IRQ5 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR2_IRQ5 = (5U << 8U) | 2U, /**< CAN0_SR2 connected to IRQ5 */
#endif
XMC_SCU_IRQCTRL_ERU0_SR2_OR_ERU1_SR2_IRQ5 = (5U << 8U) | 3U, /**< ERU0_SR2 and ERU1_SR2 connected to IRQ5 */

XMC_SCU_IRQCTRL_ERU0_SR3_IRQ6 = (6U << 8U) | 0U, /**< ERU0_SR3 connected to IRQ6 */
XMC_SCU_IRQCTRL_ERU1_SR3_IRQ6 = (6U << 8U) | 1U, /**< ERU1_SR3 connected to IRQ6 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR3_IRQ6 = (6U << 8U) | 2U, /**< CAN0_SR3 connected to IRQ6 */
#endif
XMC_SCU_IRQCTRL_ERU0_SR3_OR_ERU1_SR3_IRQ6 = (6U << 8U) | 3U, /**< ERU0_SR3 and ERU1_SR3 connected to IRQ6 */

#if defined(MATH)
XMC_SCU_IRQCTRL_MATH_SR0_IRQ7 = (7U << 8U) | 0U, /**< MATH_SR0 connected to IRQ7 */
#endif
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR3_IRQ7 = (7U << 8U) | 1U, /**< CAN0_SR3 connected to IRQ7 */
#endif
XMC_SCU_IRQCTRL_CCU40_SR1_IRQ7 = (7U << 8U) | 2U, /**< CCU40_SR1 connected to IRQ7 */
Expand Down Expand Up @@ -534,28 +534,28 @@ typedef enum XMC_SCU_IRQCTRL

XMC_SCU_IRQCTRL_VADC0_G0SR0_IRQ17 = (17U << 8U) | 0U, /**< VADC0_G0SR0 connected to IRQ17 */
XMC_SCU_IRQCTRL_USIC0_SR2_IRQ17 = (17U << 8U) | 1U, /**< USIC0_SR2 connected to IRQ17 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR0_IRQ17 = (17U << 8U) | 2U, /**< CAN0_SR0 connected to IRQ17 */
#endif
XMC_SCU_IRQCTRL_VADC0_G0SR0_OR_USIC0_SR2_IRQ17 = (17U << 8U) | 3U, /**< VADC0_G0SR0 and USIC0_SR2 connected to IRQ17 */

XMC_SCU_IRQCTRL_VADC0_G0SR1_IRQ18 = (18U << 8U) | 0U, /**< VADC0_G0SR1 connected to IRQ18 */
XMC_SCU_IRQCTRL_USIC0_SR3_IRQ18 = (18U << 8U) | 1U, /**< USIC0_SR3 connected to IRQ18 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR1_IRQ18 = (18U << 8U) | 2U, /**< CAN0_SR1 connected to IRQ18 */
#endif
XMC_SCU_IRQCTRL_VADC0_G0SR1_OR_USIC0_SR3_IRQ18 = (18U << 8U) | 3U, /**< VADC0_G0SR1 and USIC0_SR3 connected to IRQ18 */

XMC_SCU_IRQCTRL_VADC0_G1SR0_IRQ19 = (19U << 8U) | 0U, /**< VADC0_G1SR0 connected to IRQ19 */
XMC_SCU_IRQCTRL_USIC0_SR4_IRQ19 = (19U << 8U) | 1U, /**< USIC0_SR4 connected to IRQ19 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR2_IRQ19 = (19U << 8U) | 2U, /**< CAN0_SR2 connected to IRQ19 */
#endif
XMC_SCU_IRQCTRL_VADC0_G1SR0_OR_USIC0_SR4_IRQ19 = (19U << 8U) | 3U, /**< VADC0_G1SR0 and USIC0_SR4 connected to IRQ19 */

XMC_SCU_IRQCTRL_VADC0_G1SR1_IRQ20 = (20U << 8U) | 0U, /**< VADC0_G1SR1 connected to IRQ20 */
XMC_SCU_IRQCTRL_USIC0_SR5_IRQ20 = (20U << 8U) | 1U, /**< USIC0_SR5 connected to IRQ20 */
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_IRQCTRL_CAN0_SR4_IRQ20 = (20U << 8U) | 2U, /**< CAN0_SR4 connected to IRQ20 */
#endif
XMC_SCU_IRQCTRL_VADC0_G1SR1_OR_USIC0_SR5_IRQ20 = (20U << 8U) | 3U, /**< VADC0_G1SR1 and USIC0_SR5 connected to IRQ20 */
Expand Down
4 changes: 2 additions & 2 deletions cores/xmc_lib/XMCLib/inc/xmc4_scu.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ typedef enum XMC_SCU_PERIPHERAL_RESET
#if defined(LEDTS0)
XMC_SCU_PERIPHERAL_RESET_LEDTS0 = (SCU_RESET_PRSTAT1_LEDTSCU0RS_Msk | 0x10000000UL), /**< LEDTS0 reset. */
#endif
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_PERIPHERAL_RESET_MCAN = (SCU_RESET_PRSTAT1_MCAN0RS_Msk | 0x10000000UL), /**< MCAN reset. */
#endif
#if defined(DAC)
Expand Down Expand Up @@ -448,7 +448,7 @@ typedef enum XMC_SCU_PERIPHERAL_CLOCK
#if defined(LEDTS0)
XMC_SCU_PERIPHERAL_CLOCK_LEDTS0 = (SCU_CLK_CGATSTAT1_LEDTSCU0_Msk | 0x10000000UL), /**< LEDTS0 peripheral gating. */
#endif
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_PERIPHERAL_CLOCK_MCAN = (SCU_CLK_CGATSTAT1_MCAN0_Msk | 0x10000000UL), /**< MCAN peripheral gating. */
#endif
#if defined(DAC)
Expand Down
2 changes: 1 addition & 1 deletion cores/xmc_lib/XMCLib/inc/xmc_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
********************************************************************************************************************/
#include "xmc_common.h"

#if defined(CAN)
#if defined(CAN_xmc)

#include "xmc_scu.h"
#include "xmc_can_map.h"
Expand Down
2 changes: 1 addition & 1 deletion cores/xmc_lib/XMCLib/inc/xmc_pau.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ typedef enum XMC_PAU_PERIPHERAL
#if defined(BCCU0)
XMC_PAU_PERIPHERAL_BCCU0 = PAU_PRIVDIS2_PDIS15_Msk | 0x20000000U, /**< BCCU0 Privilege Disable Flag */
#endif
#if defined(CAN)
#if defined(CAN_xmc)
#if defined(CAN_NODE0)
XMC_PAU_PERIPHERAL_MCAN_NODE0_AND_GLOBAL = PAU_PRIVDIS2_PDIS21_Msk | 0x20000000U, /**< MCAN NODE0 and Global SFRs Privilege */
#endif
Expand Down
4 changes: 2 additions & 2 deletions cores/xmc_lib/XMCLib/src/xmc1_scu.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static XMC_SCU_INTERRUPT_EVENT_t event_masks[SCU_IRQ_NUM] =
#if defined(USIC1)
XMC_SCU_INTERRUPT_EVENT_PEUSIC1 |
#endif
#if defined(CAN)
#if defined(CAN_xmc)
XMC_SCU_INTERRUPT_EVENT_PEMCAN |
#endif
#if UC_SERIES == XMC14
Expand Down Expand Up @@ -282,7 +282,7 @@ __STATIC_INLINE bool XMC_SCU_INTERRUPT_IsValidEvent(XMC_SCU_INTERRUPT_EVENT_t ev
#if defined(USIC1)
(event == XMC_SCU_INTERRUPT_EVENT_PEUSIC1) ||
#endif
#if defined(CAN)
#if defined(CAN_xmc)
(event == XMC_SCU_INTERRUPT_EVENT_PEMCAN) ||
#endif
#if UC_SERIES == XMC14
Expand Down
2 changes: 1 addition & 1 deletion cores/xmc_lib/XMCLib/src/xmc_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
*******************************************************************************/
#include "xmc_can.h"

#if defined(CAN)
#if defined(CAN_xmc)
#include "xmc_scu.h"

__STATIC_INLINE uint32_t max(uint32_t a, uint32_t b)
Expand Down
Loading

0 comments on commit ba6afd4

Please sign in to comment.