IC解密NV32F100引脚图与功能及GPIO驱动程序
- IC解密#include "common.h"
- IC解密#include "systick.h"
- //#include "stdint.h"
- uint32_t cnt_start_value;
- uint32_t cnt_end_value;
- uint32_t overhead;
- SysTick_CallbackType SysTick_Callback[1] = {NULL};
- static volatile uint32_t mTicks = 0;
- #if 0
- __IO uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
- __IO uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
- __IO uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
- __I uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
- #endif
- void systick_init(void)
- {
- SysTick->VAL = 0x0; /* clear current ETMer value */
- SysTick->LOAD = 0x00FFFFFF;
- SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
- }
- void SysTick_SetCallBack(SysTick_CallbackType pSysTick_CallBack)
- {
- SysTick_Callback[0] = pSysTick_CallBack;
-
- }
- void delay_us(uint32_t us)
- {
- SysTick->CTRL =0;
- SysTick->LOAD = ((BUS_CLK_HZ/1000000)/16)*us;
- SysTick->VAL = 0;
- NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
- SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk;
- SysTick_SetCallBack(SysTick_CallBack);
- while(!mTicks);
- mTicks = 0;
- SysTick->CTRL =0; //1ض¨ê±Æ÷1ØÖD¶Ï
- }
- void delay_ms(uint32_t mstime)
- {
- delay_us(mstime*1000);
- }
- /****************************************************************************//*!
- *
- * @brief SystickÖD¶Ï·tÎñ×óoˉêy
- *
- *****************************************************************************/
- void SysTick_CallBack(void)
- {
- mTicks++;
- }
- void systick_disable(void)
- {
- SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
- }
- void cal_systick_read_overhead(void)
- {
- uint32_t cnt_start_value;
- uint32_t cnt_end_value;
-
- cnt_start_value = SysTick->VAL;
- cnt_end_value = SysTick->VAL;
-
- overhead = cnt_start_value - cnt_end_value;
-
- #ifdef DEBUG_PRINT
- printf("systick start value: 0x%x\n\r", (unsigned int)cnt_start_value);
- printf("systick end value: 0x%x\n\r", (unsigned int) cnt_end_value);
- printf("systick current value read overhead: 0x%x\n\r", (unsigned int)overhead);
- #endif
- }
- void SysTick_Isr(void)
- {
- if( SysTick_Callback[0] )
- {
- SysTick_Callback[0]();
- }
- }

芯片解密