Skip to content

Commit 0c1961a

Browse files
brondaniTomoYamanaka
authored andcommitted
CMSIS-Core(A): Fixed enumerated type increment in GIC_DistInit and GIC_CPUInterfaceInit functions
1 parent 5660256 commit 0c1961a

File tree

1 file changed

+52
-27
lines changed

1 file changed

+52
-27
lines changed

cmsis/TARGET_CORTEX_A/core_ca.h

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
* limitations under the License.
2323
*/
2424

25-
#if defined ( __ICCARM__ )
26-
#pragma system_include /* treat file as system include file for MISRA check */
25+
#if defined ( __ICCARM__ )
26+
#pragma system_include /* treat file as system include file for MISRA check */
27+
#elif defined (__clang__)
28+
#pragma clang system_header /* treat file as system include file */
2729
#endif
2830

2931
#ifdef __cplusplus
@@ -1354,8 +1356,8 @@ __STATIC_INLINE uint32_t GIC_GetGroup(IRQn_Type IRQn)
13541356
*/
13551357
__STATIC_INLINE void GIC_DistInit(void)
13561358
{
1357-
IRQn_Type i;
1358-
uint32_t num_irq = 0;
1359+
uint32_t i;
1360+
uint32_t num_irq = 0U;
13591361
uint32_t priority_field;
13601362

13611363
//A reset sets all bits in the IGROUPRs corresponding to the SPIs to 0,
@@ -1364,26 +1366,24 @@ __STATIC_INLINE void GIC_DistInit(void)
13641366
//Disable interrupt forwarding
13651367
GIC_DisableDistributor();
13661368
//Get the maximum number of interrupts that the GIC supports
1367-
num_irq = 32 * ((GIC_DistributorInfo() & 0x1f) + 1);
1369+
num_irq = 32U * ((GIC_DistributorInfo() & 0x1FU) + 1U);
13681370

13691371
/* Priority level is implementation defined.
13701372
To determine the number of priority bits implemented write 0xFF to an IPRIORITYR
13711373
priority field and read back the value stored.*/
1372-
GIC_SetPriority((IRQn_Type)0, 0xff);
1373-
priority_field = GIC_GetPriority((IRQn_Type)0);
1374+
GIC_SetPriority((IRQn_Type)0U, 0xFFU);
1375+
priority_field = GIC_GetPriority((IRQn_Type)0U);
13741376

1375-
for (i = (IRQn_Type)32; i < num_irq; i++)
1377+
for (i = 32U; i < num_irq; i++)
13761378
{
13771379
//Disable the SPI interrupt
1378-
GIC_DisableIRQ(i);
1379-
if (i > 15) {
1380-
//Set level-sensitive (and N-N model)
1381-
GIC_SetConfiguration(i, 0);
1382-
}
1380+
GIC_DisableIRQ((IRQn_Type)i);
1381+
//Set level-sensitive (and N-N model)
1382+
GIC_SetConfiguration((IRQn_Type)i, 0U);
13831383
//Set priority
1384-
GIC_SetPriority(i, priority_field/2);
1384+
GIC_SetPriority((IRQn_Type)i, priority_field/2U);
13851385
//Set target list to CPU0
1386-
GIC_SetTarget(i, 1);
1386+
GIC_SetTarget((IRQn_Type)i, 1U);
13871387
}
13881388
//Enable distributor
13891389
GIC_EnableDistributor();
@@ -1393,7 +1393,7 @@ __STATIC_INLINE void GIC_DistInit(void)
13931393
*/
13941394
__STATIC_INLINE void GIC_CPUInterfaceInit(void)
13951395
{
1396-
IRQn_Type i;
1396+
uint32_t i;
13971397
uint32_t priority_field;
13981398

13991399
//A reset sets all bits in the IGROUPRs corresponding to the SPIs to 0,
@@ -1405,27 +1405,27 @@ __STATIC_INLINE void GIC_CPUInterfaceInit(void)
14051405
/* Priority level is implementation defined.
14061406
To determine the number of priority bits implemented write 0xFF to an IPRIORITYR
14071407
priority field and read back the value stored.*/
1408-
GIC_SetPriority((IRQn_Type)0, 0xff);
1409-
priority_field = GIC_GetPriority((IRQn_Type)0);
1408+
GIC_SetPriority((IRQn_Type)0U, 0xFFU);
1409+
priority_field = GIC_GetPriority((IRQn_Type)0U);
14101410

14111411
//SGI and PPI
1412-
for (i = (IRQn_Type)0; i < 32; i++)
1412+
for (i = 0U; i < 32U; i++)
14131413
{
1414-
if(i > 15) {
1414+
if(i > 15U) {
14151415
//Set level-sensitive (and N-N model) for PPI
1416-
GIC_SetConfiguration(i, 0U);
1416+
GIC_SetConfiguration((IRQn_Type)i, 0U);
14171417
}
14181418
//Disable SGI and PPI interrupts
1419-
GIC_DisableIRQ(i);
1419+
GIC_DisableIRQ((IRQn_Type)i);
14201420
//Set priority
1421-
GIC_SetPriority(i, priority_field/2);
1421+
GIC_SetPriority((IRQn_Type)i, priority_field/2U);
14221422
}
14231423
//Enable interface
14241424
GIC_EnableInterface();
14251425
//Set binary point to 0
1426-
GIC_SetBinaryPoint(0);
1426+
GIC_SetBinaryPoint(0U);
14271427
//Set priority mask
1428-
GIC_SetInterfacePriorityMask(0xff);
1428+
GIC_SetInterfacePriorityMask(0xFFU);
14291429
}
14301430

14311431
/** \brief Initialize and enable the GIC
@@ -1477,11 +1477,36 @@ __STATIC_INLINE void PL1_SetLoadValue(uint32_t value)
14771477
/** \brief Get the current counter value.
14781478
* \return Current counter value.
14791479
*/
1480-
__STATIC_INLINE uint32_t PL1_GetCurrentValue()
1480+
__STATIC_INLINE uint32_t PL1_GetCurrentValue(void)
14811481
{
14821482
return(__get_CNTP_TVAL());
14831483
}
14841484

1485+
/** \brief Get the current physical counter value.
1486+
* \return Current physical counter value.
1487+
*/
1488+
__STATIC_INLINE uint64_t PL1_GetCurrentPhysicalValue(void)
1489+
{
1490+
return(__get_CNTPCT());
1491+
}
1492+
1493+
/** \brief Set the physical compare value.
1494+
* \param [in] value New physical timer compare value.
1495+
*/
1496+
__STATIC_INLINE void PL1_SetPhysicalCompareValue(uint64_t value)
1497+
{
1498+
__set_CNTP_CVAL(value);
1499+
__ISB();
1500+
}
1501+
1502+
/** \brief Get the physical compare value.
1503+
* \return Physical compare value.
1504+
*/
1505+
__STATIC_INLINE uint64_t PL1_GetPhysicalCompareValue(void)
1506+
{
1507+
return(__get_CNTP_CVAL());
1508+
}
1509+
14851510
/** \brief Configure the timer by setting the control value.
14861511
* \param [in] value New timer control value.
14871512
*/
@@ -1494,7 +1519,7 @@ __STATIC_INLINE void PL1_SetControl(uint32_t value)
14941519
/** \brief Get the control value.
14951520
* \return Control value.
14961521
*/
1497-
__STATIC_INLINE uint32_t PL1_GetControl()
1522+
__STATIC_INLINE uint32_t PL1_GetControl(void)
14981523
{
14991524
return(__get_CNTP_CTL());
15001525
}

0 commit comments

Comments
 (0)