MPLAB PIC32MZ-EF - Adds an assert to catch register overflow (#1265) (#1267)
Add an assert to catch register overflow (#1265)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index edda391..2765466 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,7 +7,7 @@
workflow_dispatch:
jobs:
formatting:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- name: Check Formatting of FreeRTOS-Kernel Files
diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml
index 2f36910..811c3cb 100644
--- a/.github/workflows/formatting.yml
+++ b/.github/workflows/formatting.yml
@@ -16,10 +16,11 @@
if: ${{ github.event.issue.pull_request &&
( ( github.event.comment.body == '/bot run uncrustify' ) ||
( github.event.comment.body == '/bot run formatting' ) ) }}
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
- name: Apply Formatting Fix
id: check-formatting
uses: FreeRTOS/CI-CD-Github-Actions/formatting-bot@main
with:
exclude-dirs: portable
+
diff --git a/.github/workflows/kernel-checks.yml b/.github/workflows/kernel-checks.yml
index ad3096f..0544345 100644
--- a/.github/workflows/kernel-checks.yml
+++ b/.github/workflows/kernel-checks.yml
@@ -5,7 +5,7 @@
jobs:
kernel-checker:
name: FreeRTOS Kernel Header Checks
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
# Install python 3
- name: Tool Setup
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 3591436..bc8aaf6 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -3,7 +3,7 @@
jobs:
run:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
- name: Checkout Parent Repository
uses: actions/checkout@v4.1.1
diff --git a/examples/template_configuration/FreeRTOSConfig.h b/examples/template_configuration/FreeRTOSConfig.h
index 5684e3c..5521adb 100644
--- a/examples/template_configuration/FreeRTOSConfig.h
+++ b/examples/template_configuration/FreeRTOSConfig.h
@@ -415,6 +415,8 @@
* number of the failing assert (for example, "vAssertCalled( __FILE__, __LINE__
* )" or it can simple disable interrupts and sit in a loop to halt all
* execution on the failing line for viewing in a debugger. */
+
+/* *INDENT-OFF* */
#define configASSERT( x ) \
if( ( x ) == 0 ) \
{ \
@@ -422,6 +424,7 @@
for( ; ; ) \
; \
}
+/* *INDENT-ON* */
/******************************************************************************/
/* FreeRTOS MPU specific definitions. *****************************************/
diff --git a/include/croutine.h b/include/croutine.h
index 25f4cae..a5e2e44 100644
--- a/include/croutine.h
+++ b/include/croutine.h
@@ -246,7 +246,10 @@
* \defgroup crSTART crSTART
* \ingroup Tasks
*/
+
+/* *INDENT-OFF* */
#define crEND() }
+/* *INDENT-ON* */
/*
* These macros are intended for internal use by the co-routine implementation
diff --git a/portable/MPLAB/PIC32MZ/port.c b/portable/MPLAB/PIC32MZ/port.c
index 034fc26..4af1fb8 100644
--- a/portable/MPLAB/PIC32MZ/port.c
+++ b/portable/MPLAB/PIC32MZ/port.c
@@ -234,6 +234,11 @@
{
const uint32_t ulCompareMatch = ( (configPERIPHERAL_CLOCK_HZ / portTIMER_PRESCALE) / configTICK_RATE_HZ ) - 1UL;
+ /* PR1 is 16-bit. Ensure that the configPERIPHERAL_CLOCK_HZ and
+ * configTICK_RATE_HZ are defined such that ulCompareMatch value would fit
+ * in 16-bits. */
+ configASSERT( ( ulCompareMatch & 0xFFFF0000 ) == 0 );
+
T1CON = 0x0000;
T1CONbits.TCKPS = portPRESCALE_BITS;
PR1 = ulCompareMatch;