提交 8a85ff4e 编写于 作者: G greedyhao

[bsp/bluetrum] formatting code

上级 26310fe2
...@@ -64,7 +64,8 @@ static int blehr_sample(void) ...@@ -64,7 +64,8 @@ static int blehr_sample(void)
15, 15,
1); 1);
if (tid != RT_NULL) { if (tid != RT_NULL)
{
rt_thread_startup(tid); rt_thread_startup(tid);
} }
} }
......
...@@ -26,7 +26,7 @@ void sd_mount(void *parameter) ...@@ -26,7 +26,7 @@ void sd_mount(void *parameter)
while (1) while (1)
{ {
rt_thread_mdelay(500); 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) if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
{ {
......
...@@ -182,7 +182,7 @@ void rt_hw_systick_init(void) ...@@ -182,7 +182,7 @@ void rt_hw_systick_init(void)
timer0_init(); timer0_init();
hal_set_tick_hook(timer0_cfg); 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; PICCON |= 0x10002;
} }
...@@ -224,7 +224,8 @@ void cache_init(void) ...@@ -224,7 +224,8 @@ void cache_init(void)
RT_SECTION(".irq.cache") RT_SECTION(".irq.cache")
void os_spiflash_lock(void) 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); rt_mutex_take(&mutex_spiflash, RT_WAITING_FOREVER);
} }
} }
...@@ -232,7 +233,8 @@ void os_spiflash_lock(void) ...@@ -232,7 +233,8 @@ void os_spiflash_lock(void)
RT_SECTION(".irq.cache") RT_SECTION(".irq.cache")
void os_spiflash_unlock(void) 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); rt_mutex_release(&mutex_spiflash);
} }
} }
...@@ -240,7 +242,8 @@ void os_spiflash_unlock(void) ...@@ -240,7 +242,8 @@ void os_spiflash_unlock(void)
RT_SECTION(".irq.cache") RT_SECTION(".irq.cache")
void os_cache_lock(void) 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); rt_mutex_take(&mutex_cache, RT_WAITING_FOREVER);
} }
} }
...@@ -248,7 +251,8 @@ void os_cache_lock(void) ...@@ -248,7 +251,8 @@ void os_cache_lock(void)
RT_SECTION(".irq.cache") RT_SECTION(".irq.cache")
void os_cache_unlock(void) 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); rt_mutex_release(&mutex_cache);
} }
} }
...@@ -280,5 +284,5 @@ void exception_isr(void) ...@@ -280,5 +284,5 @@ void exception_isr(void)
rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->name); rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->name);
#endif #endif
while(1); while (1);
} }
...@@ -31,13 +31,14 @@ static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size); ...@@ -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_write(long offset, const rt_uint8_t *buf, size_t size);
static int fal_flash_erase(long offset, 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", "onchip_flash",
AB32_FLASH_START_ADDRESS, AB32_FLASH_START_ADDRESS,
AB32_FLASH_SIZE, AB32_FLASH_SIZE,
AB32_FLASH_PAGE_SIZE, AB32_FLASH_PAGE_SIZE,
{NULL, fal_flash_read, fal_flash_write, fal_flash_erase}, {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) 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) ...@@ -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) 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"); rt_kprintf("Flash write requires 256 byte alignment\n");
return -1; return -1;
} }
...@@ -57,11 +59,13 @@ static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size) ...@@ -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) 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"); rt_kprintf("Flash erase requires 4096 byte alignment\n");
return -1; return -1;
} }
while (size > 0) { while (size > 0)
{
os_spiflash_erase(offset); os_spiflash_erase(offset);
offset += 4096; offset += 4096;
size -= 4096; size -= 4096;
...@@ -78,7 +82,8 @@ int fal_ops_test(void) ...@@ -78,7 +82,8 @@ int fal_ops_test(void)
int size = 256; int size = 256;
int addr = 0; int addr = 0;
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++)
{
data[i] = i; data[i] = i;
} }
...@@ -108,9 +113,11 @@ int fal_ops_test(void) ...@@ -108,9 +113,11 @@ int fal_ops_test(void)
} }
result = fal_partition_erase(part_dev, 0, 4096); result = fal_partition_erase(part_dev, 0, 4096);
if (result >= 0) { if (result >= 0)
{
rt_kprintf("Erase data success.\n"); rt_kprintf("Erase data success.\n");
} }
rt_memset(data, 0, 256); rt_memset(data, 0, 256);
result = fal_partition_read(part_dev, 0, data, 256); result = fal_partition_read(part_dev, 0, data, 256);
if (result >= 0) if (result >= 0)
......
...@@ -11,10 +11,12 @@ void hal_set_tick_hook(void (*hook)(uint32_t ticks)) ...@@ -11,10 +11,12 @@ void hal_set_tick_hook(void (*hook)(uint32_t ticks))
void hal_set_ticks(uint32_t ticks) void hal_set_ticks(uint32_t ticks)
{ {
if (ticks != hw_ticks) { if (ticks != hw_ticks)
{
hw_ticks = ticks; hw_ticks = ticks;
} }
if (tick_cfg_hook != HAL_NULL) { if (tick_cfg_hook != HAL_NULL)
{
tick_cfg_hook(hw_ticks); tick_cfg_hook(hw_ticks);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册