Skip to content

Replace systick system clock with LPTIM #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

onkwon
Copy link
Contributor

@onkwon onkwon commented Jan 13, 2024

No description provided.

@onkwon onkwon added the enhancement New feature or request label Jan 13, 2024
Copy link

Copy link

           text	   data	    bss	    dec	    hex	filename
current   21420	    124	  15216	  36760	   8f98	build/template.elf
base      20800	    124	  15208	  36132	   8d24	build/template.elf
diff        620       0       8

Copy link

[LOW] /__w/template-stm32/template-stm32/ports/stm32/board.c:37:2: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
  RCC->CSR |= RCC_CSR_LSION; /* enable LSI */
  ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/board.c:38:11: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
  while (!(RCC->CSR & RCC_CSR_LSIRDY)) { /* check if LSI is ready */
           ^

Found 2 defect(s) in board.c

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:273:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   RCC->APB1ENR1 |= RCC_APB1ENR1_LPTIM1EN;
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:274:15: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPTIM1SEL, LPTIMSEL_Val << RCC_CCIPR_LPTIM1SEL_Pos);
              ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:275:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   DBGMCU->APB1FZR1 |= DBGMCU_APB1FZR1_DBG_LPTIM1_STOP;
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:276:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   RCC->APB1RSTR1 |= RCC_APB1RSTR1_LPTIM1RST;   // Reset the LPTIM module per erratum 2.14.1.
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:277:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   RCC->APB1RSTR1 &= ~RCC_APB1RSTR1_LPTIM1RST;
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:294:17: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   configASSERT(IS_REF_CLOCK_READY());
                ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:340:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   LPTIM->IER = LPTIM_IER_CMPMIE | LPTIM_IER_CMPOKIE;   // Modify this register only when LPTIM is disabled.
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:341:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   LPTIM->CFGR = (0 << LPTIM_CFGR_PRESC_Pos);           // Modify this register only when LPTIM is disabled.
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:342:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   LPTIM->CR = LPTIM_CR_ENABLE;
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:343:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   LPTIM->ARR = 0xFFFF;        // timer period = ARR + 1.  Modify this register only when LPTIM is enabled.
   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:344:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   LPTIM->CMP = ulTimerCountsForOneTick;                // Modify this register only when LPTIM is enabled.
   ^

[MEDIUM] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:346:17: implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'uint16_t' (aka 'unsigned short') [clang-diagnostic-implicit-int-conversion]
   usIdealCmp = ulTimerCountsForOneTick;
                ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:352:4: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   LPTIM->CR |= LPTIM_CR_CNTSTRT;
   ^

[MEDIUM] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:386:29: narrowing conversion from 'unsigned long' to signed type 'int32_t' (aka 'int') is implementation-defined [bugprone-narrowing-conversions]
      int32_t lExtraError = (xExpectedIdleTime - 1UL) * LPTIM_CLOCK_HZ % configTICK_RATE_HZ;
                            ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:445:10: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
         LPTIM->CMP = usIdealCmp == 0xFFFF ? 0 : usIdealCmp;  // never write 0xFFFF to CMP (HW rule)
         ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:532:27: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
         do ulCurrCount = LPTIM->CNT; while (ulCurrCount != LPTIM->CNT);
                          ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:532:61: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
         do ulCurrCount = LPTIM->CNT; while (ulCurrCount != LPTIM->CNT);
                                                            ^

[MEDIUM] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:606:33: narrowing conversion from 'TickType_t' (aka 'unsigned int') to signed type 'int32_t' (aka 'int') is implementation-defined [bugprone-narrowing-conversions]
                  lExtraError = xFullTicksLeft * LPTIM_CLOCK_HZ % configTICK_RATE_HZ;
                                ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:620:30: Loss of precision in implicit conversion [alpha.core.Conversion]
               usIdealCmp -= ulFullTicksLeftAsCounts; // usIdealCmp is a uint16_t
                             ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:624:19: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
                  LPTIM->CMP = usIdealCmp == 0xFFFF ? 0 : usIdealCmp;  // never write 0xFFFF to CMP (HW rule)
                  ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:674:8: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   if (LPTIM->ISR & LPTIM_ISR_CMPM)
       ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:676:7: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
      LPTIM->ICR = LPTIM_ICR_CMPMCF;
      ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:687:22: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   do ulCountValue = LPTIM->CNT; while (ulCountValue != LPTIM->CNT);
                     ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:687:57: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   do ulCountValue = LPTIM->CNT; while (ulCountValue != LPTIM->CNT);
                                                        ^

[MEDIUM] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:709:20: implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'uint16_t' (aka 'unsigned short') [clang-diagnostic-implicit-int-conversion]
      usIdealCmp = ulCountValue;
                   ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:758:10: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
         LPTIM->CMP = usIdealCmp == 0xFFFF ? 0 : usIdealCmp;  // never write 0xFFFF to CMP (HW rule)
         ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:778:8: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
   if (LPTIM->ISR & LPTIM_ISR_CMPOK)
       ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:782:7: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
      LPTIM->ICR = LPTIM_ICR_CMPOKCF;
      ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:788:22: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
      if ((uint16_t)(LPTIM->CMP - usIdealCmp) > 1UL)
                     ^

[LOW] /__w/template-stm32/template-stm32/ports/stm32/lptimTick.c:790:10: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
         LPTIM->CMP = usIdealCmp == 0xFFFF ? 0 : usIdealCmp; // never write 0xFFFF to CMP (HW rule)
         ^

Found 30 defect(s) in lptimTick.c


----==== Severity Statistics ====----
----------------------------
Severity | Number of reports
----------------------------
LOW      |                28
MEDIUM   |                 4
----------------------------
----=================----

----==== Checker Statistics ====----
-----------------------------------------------------------------------
Checker name                             | Severity | Number of reports
-----------------------------------------------------------------------
performance-no-int-to-ptr                | LOW      |                27
clang-diagnostic-implicit-int-conversion | MEDIUM   |                 2
bugprone-narrowing-conversions           | MEDIUM   |                 2
alpha.core.Conversion                    | LOW      |                 1
-----------------------------------------------------------------------
----=================----

----==== File Statistics ====----
-------------------------------
File name   | Number of reports
-------------------------------
board.c     |                 2
lptimTick.c |                30
-------------------------------
----=================----

----======== Summary ========----
----------------------------------------------
Number of processed analyzer result files | 0 
Number of analyzer reports                | 32
----------------------------------------------
----=================----

Copy link

Quality Gate Passed Quality Gate passed

Issues
3 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant