[bsp/bluetrum] formatting code

This commit is contained in:
greedyhao 2021-11-30 17:26:39 +08:00
parent 26310fe254
commit 8a85ff4ebe
6 changed files with 31 additions and 17 deletions

View File

@ -64,7 +64,8 @@ static int blehr_sample(void)
15,
1);
if (tid != RT_NULL) {
if (tid != RT_NULL)
{
rt_thread_startup(tid);
}
}

View File

@ -26,7 +26,7 @@ void sd_mount(void *parameter)
while (1)
{
rt_thread_mdelay(500);
if(rt_device_find("sd0") != RT_NULL)
if (rt_device_find("sd0") != RT_NULL)
{
if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
{

View File

@ -182,7 +182,7 @@ void rt_hw_systick_init(void)
timer0_init();
hal_set_tick_hook(timer0_cfg);
hal_set_ticks(get_sysclk_nhz()/RT_TICK_PER_SECOND);
hal_set_ticks(get_sysclk_nhz() / RT_TICK_PER_SECOND);
PICCON |= 0x10002;
}
@ -224,7 +224,8 @@ void cache_init(void)
RT_SECTION(".irq.cache")
void os_spiflash_lock(void)
{
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
{
rt_mutex_take(&mutex_spiflash, RT_WAITING_FOREVER);
}
}
@ -232,7 +233,8 @@ void os_spiflash_lock(void)
RT_SECTION(".irq.cache")
void os_spiflash_unlock(void)
{
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
{
rt_mutex_release(&mutex_spiflash);
}
}
@ -240,7 +242,8 @@ void os_spiflash_unlock(void)
RT_SECTION(".irq.cache")
void os_cache_lock(void)
{
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
{
rt_mutex_take(&mutex_cache, RT_WAITING_FOREVER);
}
}
@ -248,7 +251,8 @@ void os_cache_lock(void)
RT_SECTION(".irq.cache")
void os_cache_unlock(void)
{
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
{
rt_mutex_release(&mutex_cache);
}
}
@ -280,5 +284,5 @@ void exception_isr(void)
rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->name);
#endif
while(1);
while (1);
}

View File

@ -31,13 +31,14 @@ static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);
static int fal_flash_erase(long offset, size_t size);
const struct fal_flash_dev ab32_onchip_flash = {
const struct fal_flash_dev ab32_onchip_flash =
{
"onchip_flash",
AB32_FLASH_START_ADDRESS,
AB32_FLASH_SIZE,
AB32_FLASH_PAGE_SIZE,
{NULL, fal_flash_read, fal_flash_write, fal_flash_erase},
256*8
256 * 8
};
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size)
@ -47,7 +48,8 @@ static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size)
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size)
{
if (size % 256) {
if (size % 256)
{
rt_kprintf("Flash write requires 256 byte alignment\n");
return -1;
}
@ -57,11 +59,13 @@ static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size)
static int fal_flash_erase(long offset, size_t size)
{
if (size % 4096) {
if (size % 4096)
{
rt_kprintf("Flash erase requires 4096 byte alignment\n");
return -1;
}
while (size > 0) {
while (size > 0)
{
os_spiflash_erase(offset);
offset += 4096;
size -= 4096;
@ -78,7 +82,8 @@ int fal_ops_test(void)
int size = 256;
int addr = 0;
for (int i = 0; i < 256; i++) {
for (int i = 0; i < 256; i++)
{
data[i] = i;
}
@ -108,9 +113,11 @@ int fal_ops_test(void)
}
result = fal_partition_erase(part_dev, 0, 4096);
if (result >= 0) {
if (result >= 0)
{
rt_kprintf("Erase data success.\n");
}
rt_memset(data, 0, 256);
result = fal_partition_read(part_dev, 0, data, 256);
if (result >= 0)

View File

@ -11,10 +11,12 @@ void hal_set_tick_hook(void (*hook)(uint32_t ticks))
void hal_set_ticks(uint32_t ticks)
{
if (ticks != hw_ticks) {
if (ticks != hw_ticks)
{
hw_ticks = ticks;
}
if (tick_cfg_hook != HAL_NULL) {
if (tick_cfg_hook != HAL_NULL)
{
tick_cfg_hook(hw_ticks);
}
}