Skip to content
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

[WB32 MCU] Fixed bugs #367

Merged
merged 10 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demos/WB32/RT-WB32FQ95-GENERIC/cfg/halconf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,7 @@
#define HALCONF_H

#define _CHIBIOS_HAL_CONF_
#define _CHIBIOS_HAL_CONF_VER_8_0_
#define _CHIBIOS_HAL_CONF_VER_8_4_

#include "mcuconf.h"

Expand Down
29 changes: 3 additions & 26 deletions demos/WB32/RT-WB32FQ95-GENERIC/keil/ch.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
Expand Down Expand Up @@ -101,9 +101,7 @@
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>4</nTsel>
<nTsel>3</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
Expand Down Expand Up @@ -148,24 +146,7 @@
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>47</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
Expand Down Expand Up @@ -204,10 +185,6 @@
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
</TargetOption>
</Target>

Expand Down
12 changes: 4 additions & 8 deletions demos/WB32/RT-WB32FQ95-GENERIC/keil/ch.uvprojx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
<TargetName>Demo</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
<uAC6>0</uAC6>
<pCCUsed>5060422::V5.06 update 4 (build 422)::ARMCC</pCCUsed>
<TargetOption>
<TargetCommonOption>
<Device>ARMCM3</Device>
<Vendor>ARM</Vendor>
<PackID>ARM.CMSIS.5.8.0</PackID>
<PackID>ARM.CMSIS.5.6.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M3") CLOCK(12000000) ESEL ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
Expand Down Expand Up @@ -184,8 +183,6 @@
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsMve>0</RvdsMve>
<RvdsCdeCp>0</RvdsCdeCp>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
Expand Down Expand Up @@ -326,7 +323,6 @@
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>0</uGnu>
<useXO>0</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
Expand All @@ -339,7 +335,7 @@
<MiscControls>-UWB32FQ95xx</MiscControls>
<Define>CORTEX_USE_FPU=0 TEST_CFG_SIZE_REPORT=0 __heap_base__=Image$$$$RW_IRAM1$$$$ZI$$$$Limit __heap_end__=Image$$$$RW_IRAM1$$$$Base</Define>
<Undefine></Undefine>
<IncludePath>..\;..\cfg;..\..\..\..\..\ChibiOS\os\license;..\..\..\..\..\ChibiOS-Contrib\os\common\startup\ARMCMx\devices\WB32FQ95xx;..\..\..\..\..\ChibiOS\os\common\ext\ARM\CMSIS\Core\Include;..\..\..\..\..\ChibiOS-Contrib\os\common\ext\CMSIS\WB32\WB32FQ95xx;..\..\..\..\..\ChibiOS\os\common\portability\Keil;..\..\..\..\..\ChibiOS\os\common\ports\ARM-common;..\..\..\..\..\ChibiOS\os\common\ports\ARMv7-M;..\..\..\..\..\ChibiOS\os\rt\include;..\..\..\..\..\ChibiOS\os\oslib\include;..\..\..\..\..\ChibiOS\os\hal\osal\rt-nil;..\..\..\..\..\ChibiOS\os\hal\include;..\board;..\..\..\..\..\ChibiOS\os\hal\ports\common\ARMCMx;..\..\..\..\..\ChibiOS-Contrib\os\hal\ports\WB32\WB32FQ95xx;..\..\..\..\..\ChibiOS-Contrib\os\hal\ports\WB32\LLD\GPIOv1;..\..\..\..\os\hal\ports\WB32\LLD\TIMv1;..\..\..\..\..\ChibiOS\os\test\include;..\..\..\..\..\ChibiOS\test\rt\source\test;..\..\..\..\..\ChibiOS\test\oslib\source\test</IncludePath>
<IncludePath>..\;..\cfg;..\..\..\..\..\ChibiOS\os\license;..\..\..\..\..\ChibiOS-Contrib\os\common\startup\ARMCMx\devices\WB32FQ95xx;..\..\..\..\..\ChibiOS\os\common\ext\ARM\CMSIS\Core\Include;..\..\..\..\..\ChibiOS-Contrib\os\common\ext\CMSIS\WB32\WB32FQ95xx;..\..\..\..\..\ChibiOS\os\common\portability\Keil;..\..\..\..\..\ChibiOS\os\common\ports\ARM-common;..\..\..\..\..\ChibiOS\os\common\ports\ARMv7-M;..\..\..\..\..\ChibiOS\os\rt\include;..\..\..\..\..\ChibiOS\os\oslib\include;..\..\..\..\..\ChibiOS\os\hal\osal\rt-nil;..\..\..\..\..\ChibiOS\os\hal\include;..\board;..\..\..\..\..\ChibiOS\os\hal\ports\common\ARMCMx;..\..\..\..\..\ChibiOS-Contrib\os\hal\ports\WB32\WB32FQ95xx;..\..\..\..\..\ChibiOS-Contrib\os\hal\ports\WB32\LLD\GPIOv1;..\..\..\..\os\hal\ports\WB32\LLD\DMAv1;..\..\..\..\os\hal\ports\WB32\LLD\TIMv1;..\..\..\..\..\ChibiOS\os\test\include;..\..\..\..\..\ChibiOS\test\rt\source\test;..\..\..\..\..\ChibiOS\test\oslib\source\test</IncludePath>
</VariousControls>
</Cads>
<Aads>
Expand All @@ -352,7 +348,7 @@
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<ClangAsOpt>4</ClangAsOpt>
<uClangAs>0</uClangAs>
<VariousControls>
<MiscControls>--cpreproc --cpreproc_opts=-DCORTEX_USE_FPU=0</MiscControls>
<Define></Define>
Expand Down
8 changes: 6 additions & 2 deletions os/hal/ports/WB32/LLD/GPIOv1/hal_pal_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ void _pal_lld_enablepadevent(ioportid_t port,
else
EXTI->FTSR &= ~padmask;

EXTI->PR = padmask;

/* Programming interrupt and event registers.*/
EXTI->IMR |= padmask;
EXTI->EMR &= ~padmask;
Expand Down Expand Up @@ -204,8 +206,10 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
EXTI->FTSR = ftsr1 & ~padmask;
EXTI->PR = padmask;

/* Disable EXTI clock.*/
rccDisableEXTI();
if ((!EXTI->IMR) && (!EXTI->EMR)) {
/* Disable EXTI clock.*/
rccDisableEXTI();
}

#if PAL_USE_CALLBACKS || PAL_USE_WAIT
/* Callback cleared and/or thread reset.*/
Expand Down
6 changes: 6 additions & 0 deletions os/hal/ports/WB32/LLD/USBv1/hal_usb_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ static void usb_serve_epin_handler(USBDriver *usbp, usbep_t ep) {
/* IN endpoint, transmission.*/
USBInEndpointState *isp = epcp->in_state;

if (isp->txcnt >= isp->txsize) {
/* Transfer completed, invokes the callback.*/
_usb_isr_invoke_in_cb(usbp, ep);
return;
}

WB32_USB->INDEX = ep;

isp->txcnt += isp->txlast;
Expand Down
42 changes: 27 additions & 15 deletions os/hal/ports/WB32/WB32F3G71xx/hal_efl_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @addtogroup HAL_EFL
* @{
*/

#include <string.h>

#include "hal.h"
Expand Down Expand Up @@ -308,29 +308,34 @@ flash_error_t efl_lld_program(void *instance, flash_offset_t offset,

memcpy((void *)&line.b[0], (const void *)address, WB32_FLASH_PAGE_SIZE);

/* Copying data inside the prepared page.*/
do {
line.b[offset & WB32_FLASH_PAGE_MASK] = *pp;
offset++;
n--;
pp++;
} while ((n > 0U) & ((offset & WB32_FLASH_PAGE_MASK) != 0U));

#ifndef WB32_FLASH_PROGRAM_NO_ERASE
bool ferase = true;
#else
bool ferase = false;
to_erase:
#endif
/* Erase page. */
err = wb32_flash_erase_page(devp, (uint32_t)address);
if (err != FLASH_NO_ERROR) {
break;
if (ferase) {
err = wb32_flash_erase_page(devp, (uint32_t)address);
if (err != FLASH_NO_ERROR) {
break;
}
}
#endif

/* Clear page latch. */
err = wb32_flash_clear_page_latch(devp);
if (err != FLASH_NO_ERROR) {
break;
}

/* Copying data inside the prepared page.*/
do {
line.b[offset & WB32_FLASH_PAGE_MASK] = *pp;
offset++;
n--;
pp++;
}
while ((n > 0U) & ((offset & WB32_FLASH_PAGE_MASK) != 0U));

for (int i = 0; i < (WB32_FLASH_PAGE_SIZE / sizeof(uint32_t)); i++) {
devp->flash->BUF[i] = line.w[i];
}
Expand All @@ -340,8 +345,15 @@ flash_error_t efl_lld_program(void *instance, flash_offset_t offset,
if (err != FLASH_NO_ERROR) {
break;
}

/* Check for flash error.*/
if (address[0] != line.w[0]) {
if (memcmp(&line.w[0], (void *)address, WB32_FLASH_PAGE_SIZE) != 0) {
#ifdef WB32_FLASH_PROGRAM_NO_ERASE
if (!ferase) {
ferase = true;
goto to_erase;
}
#endif
err = FLASH_ERROR_PROGRAM;
break;
}
Expand Down
Loading
Loading