Skip to content

Commit

Permalink
Merge pull request #71 from Community-PIO-CH32V/update/sdk
Browse files Browse the repository at this point in the history
Adapt examples for updated SDKs
  • Loading branch information
maxgerhardt authored Sep 15, 2024
2 parents ccc7ebe + 739f2bd commit 7248202
Show file tree
Hide file tree
Showing 18 changed files with 330 additions and 546 deletions.
6 changes: 5 additions & 1 deletion examples/blinky-cpp-none-os/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ LEDBlinker blinker(BLINKY_GPIO_PORT, BLINKY_GPIO_PIN, BLINKY_CLOCK);

int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#ifdef NVIC_PriorityGroup_2
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
#else
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#endif
SystemCoreClockUpdate();
Delay_Init();

Expand Down
6 changes: 5 additions & 1 deletion examples/blinky-freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ void task2_task(void *pvParameters)

int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#ifdef NVIC_PriorityGroup_2
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
#else
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#endif
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
Expand Down
4 changes: 4 additions & 0 deletions examples/blinky-none-os/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ void Delay_Ms(uint32_t n);

int main(void)
{
#ifdef NVIC_PriorityGroup_2
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
#else
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#endif
SystemCoreClockUpdate();
Delay_Init();

Expand Down
6 changes: 5 additions & 1 deletion examples/hello-world-harmony-liteos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ LITE_OS_SEC_TEXT_INIT int main(void)
{
unsigned int ret;

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#ifdef NVIC_PriorityGroup_2
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
#else
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#endif
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
Expand Down
4 changes: 4 additions & 0 deletions examples/sdi-printf-ch32v003/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ int main(void)
{
u8 i = 0;

#ifdef NVIC_PriorityGroup_2
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
#else
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#endif
Delay_Init();
#if (SDI_PRINT == SDI_PR_OPEN)
SDI_Printf_Enable();
Expand Down
4 changes: 4 additions & 0 deletions examples/uart-printf-none-os/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

int main(void)
{
#ifdef NVIC_PriorityGroup_2
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
#else
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#endif
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
Expand Down
6 changes: 5 additions & 1 deletion examples/usb-pd-none-os/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ void TIM1_Init(u16 arr, u16 psc)
*/
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#ifdef NVIC_PriorityGroup_2
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
#else
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
#endif
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(921600);
Expand Down
30 changes: 26 additions & 4 deletions examples/webserver-ch32v307-none-os/lib/HTTP/HTTPS.c
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,28 @@ char * DataLocate(char *buf, char *name)
return p;
}

/*********************************************************************
* @fn atoh
*
* @brief Converting character to hexadecimal number
*
* @param src - character
*
* @return hexadecimal number
*/
uint8_t atoh(uint8_t *src)
{
uint8_t desc=0;

if((*src >= '0') && (*src <= '9'))
desc = *src - 0x30;
else if((*src >= 'a') && (*src <= 'f'))
desc = *src - 0x57;
else if((*src >= 'A') && (*src <= 'F'))
desc = *src - 0x37;

return desc;
}
/*********************************************************************
* @fn Refresh_Basic
*
Expand Down Expand Up @@ -2368,10 +2390,10 @@ void Refresh_Basic(u8 *buf)
if(q == NULL) return;
memcpy(temp, p, (q - p));
p = strtok(temp, ".");
BasicCfg.mac[0] = atoi(p);
(strlen(p) == 1) ? (BasicCfg.mac[0] = atoh(p)) : (BasicCfg.mac[0] = atoh(p) << 4 | atoh(p + 1));
for (i = 1; i < 6; i++) {
p = strtok(NULL, ".");
BasicCfg.mac[i] = atoi(p);
(strlen(p) == 1) ? (BasicCfg.mac[i] = atoh(p)) : (BasicCfg.mac[i] = atoh(p) << 4 | atoh(p + 1));
}
}
else return;
Expand Down Expand Up @@ -2790,11 +2812,11 @@ void Init_Para_Tab(void)

Para_Basic[0].para = "__AMAC";
memset(s, 0, 30);
snprintf(s, 30, "%d.%d.%d.%d.%d.%d", Basic_CfgBuf.mac[0], Basic_CfgBuf.mac[1],
snprintf(s, 30, "%x.%x.%x.%x.%x.%x", Basic_CfgBuf.mac[0], Basic_CfgBuf.mac[1],
Basic_CfgBuf.mac[2], Basic_CfgBuf.mac[3], Basic_CfgBuf.mac[4],
Basic_CfgBuf.mac[5]);
strcpy(Para_Basic[0].value, s);
printf("__ASIP = %s\n", Para_Basic[0].value);
printf("__ASMAC = %s\n", Para_Basic[0].value);

Para_Basic[1].para = "__ASIP";
memset(s, 0, 30);
Expand Down
Loading

0 comments on commit 7248202

Please sign in to comment.