import: pb5700_sdk-FPGA package
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# component Makefile
|
||||
#
|
||||
|
||||
|
||||
C_SOURCES += \
|
||||
$(srctree)/$(PROJ)/src/isr.c \
|
||||
$(srctree)/$(PROJ)/src/main.c
|
||||
|
||||
C_INCLUDES += -I$(srctree)/$(PROJ)/inc
|
||||
|
||||
|
||||
LIBS +=
|
||||
CFLAGS +=
|
||||
LDFLAGS +=
|
||||
LIBDIR +=
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
|
||||
*/
|
||||
/** @file isr.h
|
||||
*
|
||||
* @author Wei-Lun Hsu
|
||||
* @version 0.1
|
||||
* @date 2024/09/16
|
||||
* @license
|
||||
* @description
|
||||
*/
|
||||
|
||||
#ifndef __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
|
||||
#define __isr_H_wuraIpBA_lTJm_HvJw_sNDo_uEd5JnucTReY__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
//=============================================================================
|
||||
// Constant Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Macro Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Structure Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Global Data Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Private Function Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Public Function Definition
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
|
||||
*/
|
||||
/** @file main.h
|
||||
*
|
||||
* @author Wei-Lun Hsu
|
||||
* @version 0.1
|
||||
* @date 2024/08/29
|
||||
* @license
|
||||
* @description
|
||||
*/
|
||||
|
||||
#ifndef __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
|
||||
#define __main_H_wxBnwdPw_lq7D_H4I5_sHPp_uXof15pFLp4V__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "hal_device.h"
|
||||
#include "syslog.h"
|
||||
//=============================================================================
|
||||
// Constant Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Macro Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Structure Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Global Data Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Private Function Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Public Function Definition
|
||||
//=============================================================================
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
sys_tick_src
|
||||
---
|
||||
|
||||
This example is used to configure the clock source of systick
|
||||
> clock source of systick
|
||||
> + LSI
|
||||
> + HSI with divider 2/4/8
|
||||
|
||||
|
||||
## Log
|
||||
|
||||
Use serial port with baudrate 115200, 8bit, no parity check.
|
||||
|
||||
```
|
||||
Sep 25 2025 13:23:03
|
||||
This is a demo projec to configure source of systick
|
||||
current tick source: LSI
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 0
|
||||
delay 1 sec
|
||||
current tick source: HSI/2
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 1
|
||||
delay 1 sec
|
||||
current tick source: HSI/4
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 2
|
||||
delay 1 sec
|
||||
current tick source: HSI/8
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 3
|
||||
delay 1 sec
|
||||
current tick source: LSI
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 0
|
||||
delay 1 sec
|
||||
current tick source: HSI/2
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 1
|
||||
delay 1 sec
|
||||
current tick source: HSI/4
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 2
|
||||
delay 1 sec
|
||||
current tick source: HSI/8
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 3
|
||||
delay 1 sec
|
||||
current tick source: LSI
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 0
|
||||
delay 1 sec
|
||||
current tick source: HSI/2
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 1
|
||||
delay 1 sec
|
||||
current tick source: HSI/4
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 2
|
||||
delay 1 sec
|
||||
current tick source: HSI/8
|
||||
SYSCFG->SYSCLKCR_b.SYSTICKCR= 3
|
||||
delay 1 sec
|
||||
...
|
||||
```
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
|
||||
*/
|
||||
/** @file isr.c
|
||||
*
|
||||
* @author Wei-Lun Hsu
|
||||
* @version 0.1
|
||||
* @date 2024/09/16
|
||||
* @license
|
||||
* @description
|
||||
*/
|
||||
|
||||
|
||||
#include "isr.h"
|
||||
|
||||
//=============================================================================
|
||||
// Constant Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Macro Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Structure Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Global Data Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Private Function Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Public Function Definition
|
||||
//=============================================================================
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
|
||||
*/
|
||||
/** @file main.c
|
||||
*
|
||||
* @author Wei-Lun Hsu
|
||||
* @version 0.1
|
||||
* @date 2024/08/29
|
||||
* @license
|
||||
* @description
|
||||
*/
|
||||
|
||||
|
||||
#include "main.h"
|
||||
#include "isr.h"
|
||||
//=============================================================================
|
||||
// Constant Definition
|
||||
//=============================================================================
|
||||
#define CONFIG_TOGGLE_IO_PORT GPIOA
|
||||
#define CONFIG_TOGGLE_IO_PIN GPIO_Pin_00
|
||||
|
||||
//=============================================================================
|
||||
// Macro Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Structure Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Global Data Definition
|
||||
//=============================================================================
|
||||
|
||||
//=============================================================================
|
||||
// Private Function Definition
|
||||
//=============================================================================
|
||||
|
||||
static void _Config_IO(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
GPIO_InitStruct.GPIO_Pin = CONFIG_TOGGLE_IO_PIN;
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_Init(CONFIG_TOGGLE_IO_PORT, &GPIO_InitStruct);
|
||||
return;
|
||||
}
|
||||
|
||||
__INTERRUPT void _mtim_handler(void)
|
||||
{
|
||||
SAVE_IRQ_CSR_CONTEXT();
|
||||
|
||||
GPIO_TogglePin(CONFIG_TOGGLE_IO_PORT, CONFIG_TOGGLE_IO_PIN);
|
||||
|
||||
// Reload Timer Interrupt
|
||||
SysTick_Reload(g_SysTickPeriod);
|
||||
|
||||
RESTORE_IRQ_CSR_CONTEXT();
|
||||
return;
|
||||
}
|
||||
//=============================================================================
|
||||
// Public Function Definition
|
||||
//=============================================================================
|
||||
int main(void)
|
||||
{
|
||||
int cnt = 0;
|
||||
SYSCFG_ClkInitTypeDef SysClkInit = {0};
|
||||
|
||||
#if 1
|
||||
SysClkInit.ClkSource = SYSCFG_ClkSrc_HSI;
|
||||
#else
|
||||
SysClkInit.ClkSource = SYSCFG_ClkSrc_FreqDiv;
|
||||
SysClkInit.SysClk_Div = SYSCFG_SysClkDiv2;
|
||||
#endif
|
||||
|
||||
SYSCFG_SysClkConfig(&SysClkInit);
|
||||
|
||||
sys_config_systick(SYS_TICK_1_MS);
|
||||
|
||||
syslog_init();
|
||||
|
||||
info("%s %s\nThis is a demo projec to configure source of systick\n",
|
||||
__DATE__, __TIME__);
|
||||
|
||||
while(1)
|
||||
{
|
||||
SYSCFG_SysTickSrcTypeDef tick_src = SYSCFG_SysTickSrc_LSI;
|
||||
|
||||
sys_disable_systick();
|
||||
|
||||
switch( cnt & 0x3 )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_LSI);
|
||||
break;
|
||||
case 1:
|
||||
SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_HSI_Div2);
|
||||
break;
|
||||
case 2:
|
||||
SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_HSI_Div4);
|
||||
break;
|
||||
case 3:
|
||||
SYSCFG_SetSysTickSrc(SYSCFG_SysTickSrc_HSI_Div8);
|
||||
break;
|
||||
}
|
||||
|
||||
cnt++;
|
||||
|
||||
sys_config_systick(SYS_TICK_1_MS);
|
||||
|
||||
tick_src = SYSCFG_GetSysTickSrc();
|
||||
|
||||
msg(" current tick source: %s\n",
|
||||
(tick_src == SYSCFG_SysTickSrc_HSI_Div2) ? "HSI/2" :
|
||||
(tick_src == SYSCFG_SysTickSrc_HSI_Div4) ? "HSI/4" :
|
||||
(tick_src == SYSCFG_SysTickSrc_HSI_Div8) ? "HSI/8" :
|
||||
"LSI");
|
||||
|
||||
msg("SYSCFG->SYSCLKCR_b.SYSTICKCR= %d\n", SYSCFG->SYSCLKCR_b.SYSTICKCR);
|
||||
|
||||
msg("delay 1 sec\n");
|
||||
sys_delay(1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user