Skip to content

Commit

Permalink
uniform code writing-disable interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
thewon86 authored and Guozhanxin committed Apr 20, 2022
1 parent 5fa15a1 commit f5b0bfd
Show file tree
Hide file tree
Showing 47 changed files with 293 additions and 290 deletions.
4 changes: 2 additions & 2 deletions components/drivers/audio/audio_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static rt_size_t rt_pipe_read(rt_device_t dev,
void *buffer,
rt_size_t size)
{
rt_uint32_t level;
rt_base_t level;
rt_thread_t thread;
struct rt_audio_pipe *pipe;
rt_size_t read_nbytes;
Expand Down Expand Up @@ -119,7 +119,7 @@ static rt_size_t rt_pipe_write(rt_device_t dev,
const void *buffer,
rt_size_t size)
{
rt_uint32_t level;
rt_base_t level;
rt_thread_t thread;
struct rt_audio_pipe *pipe;
rt_size_t write_nbytes;
Expand Down
12 changes: 6 additions & 6 deletions components/drivers/ipc/dataqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
rt_size_t data_size,
rt_int32_t timeout)
{
rt_ubase_t level;
rt_base_t level;
rt_thread_t thread;
rt_err_t result;

Expand Down Expand Up @@ -208,7 +208,7 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
rt_size_t *size,
rt_int32_t timeout)
{
rt_ubase_t level;
rt_base_t level;
rt_thread_t thread;
rt_err_t result;

Expand Down Expand Up @@ -330,7 +330,7 @@ rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
const void** data_ptr,
rt_size_t *size)
{
rt_ubase_t level;
rt_base_t level;

RT_ASSERT(queue != RT_NULL);
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
Expand Down Expand Up @@ -361,7 +361,7 @@ RTM_EXPORT(rt_data_queue_peek);
*/
void rt_data_queue_reset(struct rt_data_queue *queue)
{
rt_ubase_t level;
rt_base_t level;
struct rt_thread *thread;

RT_ASSERT(queue != RT_NULL);
Expand Down Expand Up @@ -441,7 +441,7 @@ RTM_EXPORT(rt_data_queue_reset);
*/
rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
{
rt_ubase_t level;
rt_base_t level;

RT_ASSERT(queue != RT_NULL);
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
Expand All @@ -468,7 +468,7 @@ RTM_EXPORT(rt_data_queue_deinit);
*/
rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue)
{
rt_ubase_t level;
rt_base_t level;
rt_int16_t len;

RT_ASSERT(queue != RT_NULL);
Expand Down
14 changes: 7 additions & 7 deletions components/drivers/pm/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void rt_pm_request(rt_uint8_t mode)
*/
void rt_pm_release(rt_uint8_t mode)
{
rt_ubase_t level;
rt_base_t level;
struct rt_pm *pm;

if (_pm_init_flag == 0)
Expand All @@ -535,7 +535,7 @@ void rt_pm_release(rt_uint8_t mode)
*/
void rt_pm_release_all(rt_uint8_t mode)
{
rt_ubase_t level;
rt_base_t level;
struct rt_pm *pm;

if (_pm_init_flag == 0)
Expand Down Expand Up @@ -589,7 +589,7 @@ void rt_pm_module_request(uint8_t module_id, rt_uint8_t mode)
*/
void rt_pm_module_release(uint8_t module_id, rt_uint8_t mode)
{
rt_ubase_t level;
rt_base_t level;
struct rt_pm *pm;

if (_pm_init_flag == 0)
Expand Down Expand Up @@ -620,7 +620,7 @@ void rt_pm_module_release(uint8_t module_id, rt_uint8_t mode)
*/
void rt_pm_module_release_all(uint8_t module_id, rt_uint8_t mode)
{
rt_ubase_t level;
rt_base_t level;
struct rt_pm *pm;

if (_pm_init_flag == 0)
Expand All @@ -646,7 +646,7 @@ void rt_pm_module_release_all(uint8_t module_id, rt_uint8_t mode)
*/
void rt_pm_sleep_request(rt_uint16_t module_id, rt_uint8_t mode)
{
rt_uint32_t level;
rt_base_t level;

if (module_id >= PM_MODULE_MAX_ID)
{
Expand Down Expand Up @@ -709,7 +709,7 @@ void rt_pm_sleep_light_request(rt_uint16_t module_id)
*/
void rt_pm_sleep_release(rt_uint16_t module_id, rt_uint8_t mode)
{
rt_uint32_t level;
rt_base_t level;

if (module_id >= PM_MODULE_MAX_ID)
{
Expand Down Expand Up @@ -797,7 +797,7 @@ void rt_pm_device_register(struct rt_device *device, const struct rt_device_pm_o
*/
void rt_pm_device_unregister(struct rt_device *device)
{
rt_ubase_t level;
rt_base_t level;
rt_uint32_t index;
RT_DEBUG_NOT_IN_INTERRUPT;

Expand Down
2 changes: 1 addition & 1 deletion components/drivers/spi/enc28j60.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static uint8_t spi_read_op(struct rt_spi_device *spi_device, uint8_t op, uint8_t

static void spi_write_op(struct rt_spi_device *spi_device, uint8_t op, uint8_t address, uint8_t data)
{
uint32_t level;
rt_base_t level;
uint8_t buffer[2];

level = rt_hw_interrupt_disable();
Expand Down
16 changes: 8 additions & 8 deletions components/drivers/usb/usbdevice/class/cdc_vcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@ static void rt_usb_vcom_init(struct ufunction *func);
static void _vcom_reset_state(ufunction_t func)
{
struct vcom* data;
int lvl;
rt_base_t level;

RT_ASSERT(func != RT_NULL)

data = (struct vcom*)func->user_data;

lvl = rt_hw_interrupt_disable();
level = rt_hw_interrupt_disable();
data->connected = RT_FALSE;
data->in_sending = RT_FALSE;
/*rt_kprintf("reset USB serial\n", cnt);*/
rt_hw_interrupt_enable(lvl);
rt_hw_interrupt_enable(level);
}

/**
Expand Down Expand Up @@ -320,7 +320,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
*/
static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
{
rt_uint32_t level;
rt_base_t level;
struct vcom *data;

RT_ASSERT(func != RT_NULL);
Expand Down Expand Up @@ -687,7 +687,7 @@ static int _vcom_getc(struct rt_serial_device *serial)
{
int result;
rt_uint8_t ch;
rt_uint32_t level;
rt_base_t level;
struct ufunction *func;
struct vcom *data;

Expand All @@ -710,7 +710,7 @@ static int _vcom_getc(struct rt_serial_device *serial)

static rt_size_t _vcom_rb_block_put(struct vcom *data, const rt_uint8_t *buf, rt_size_t size)
{
rt_uint32_t level;
rt_base_t level;
rt_size_t put_len = 0;
rt_size_t w_ptr = 0;
rt_uint32_t res;
Expand Down Expand Up @@ -799,7 +799,7 @@ static rt_size_t _vcom_tx(struct rt_serial_device *serial, rt_uint8_t *buf, rt_s
}
static int _vcom_putc(struct rt_serial_device *serial, char c)
{
rt_uint32_t level;
rt_base_t level;
struct ufunction *func;
struct vcom *data;

Expand Down Expand Up @@ -838,7 +838,7 @@ static const struct rt_uart_ops usb_vcom_ops =
/* Vcom Tx Thread */
static void vcom_tx_thread_entry(void* parameter)
{
rt_uint32_t level;
rt_base_t level;
rt_uint32_t res;
struct ufunction *func = (struct ufunction *)parameter;
struct vcom *data = (struct vcom*)func->user_data;
Expand Down
22 changes: 11 additions & 11 deletions components/finsh/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void list_find_init(list_get_next_t *p, rt_uint8_t type, rt_list_t **arra
static rt_list_t *list_get_next(rt_list_t *current, list_get_next_t *arg)
{
int first_flag = 0;
rt_ubase_t level;
rt_base_t level;
rt_list_t *node, *list;
rt_list_t **array;
int nr;
Expand Down Expand Up @@ -153,7 +153,7 @@ static rt_list_t *list_get_next(rt_list_t *current, list_get_next_t *arg)

long list_thread(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -267,7 +267,7 @@ static void show_wait_queue(struct rt_list_node *list)
#ifdef RT_USING_SEMAPHORE
long list_sem(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -334,7 +334,7 @@ MSH_CMD_EXPORT(list_sem, list semaphore in system);
#ifdef RT_USING_EVENT
long list_event(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -399,7 +399,7 @@ MSH_CMD_EXPORT(list_event, list event in system);
#ifdef RT_USING_MUTEX
long list_mutex(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -457,7 +457,7 @@ MSH_CMD_EXPORT(list_mutex, list mutex in system);
#ifdef RT_USING_MAILBOX
long list_mailbox(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -528,7 +528,7 @@ MSH_CMD_EXPORT(list_mailbox, list mail box in system);
#ifdef RT_USING_MESSAGEQUEUE
long list_msgqueue(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -595,7 +595,7 @@ MSH_CMD_EXPORT(list_msgqueue, list message queue in system);
#ifdef RT_USING_MEMHEAP
long list_memheap(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -652,7 +652,7 @@ MSH_CMD_EXPORT(list_memheap, list memory heap in system);
#ifdef RT_USING_MEMPOOL
long list_mempool(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -731,7 +731,7 @@ MSH_CMD_EXPORT(list_mempool, list memory pool in system);

long list_timer(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down Expand Up @@ -829,7 +829,7 @@ static char *const device_type_str[RT_Device_Class_Unknown] =

long list_device(void)
{
rt_ubase_t level;
rt_base_t level;
list_get_next_t find_arg;
rt_list_t *obj_list[LIST_FIND_OBJ_NR];
rt_list_t *next = (rt_list_t *)RT_NULL;
Expand Down
2 changes: 1 addition & 1 deletion components/finsh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ rt_uint32_t finsh_get_echo()
*/
rt_err_t finsh_set_password(const char *password)
{
rt_ubase_t level;
rt_base_t level;
rt_size_t pw_len = rt_strlen(password);

if (pw_len < FINSH_PASSWORD_MIN || pw_len > FINSH_PASSWORD_MAX)
Expand Down
8 changes: 4 additions & 4 deletions components/libc/compilers/common/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ RTM_EXPORT(nanosleep);
static volatile struct timeval _timevalue;
static int _rt_clock_time_system_init(void)
{
register rt_base_t level;
rt_base_t level;
time_t time = 0;
rt_tick_t tick;
rt_device_t device;
Expand Down Expand Up @@ -593,7 +593,7 @@ int clock_gettime(clockid_t clockid, struct timespec *tp)
case CLOCK_REALTIME:
{
int tick;
register rt_base_t level;
rt_base_t level;

level = rt_hw_interrupt_disable();
tick = rt_tick_get(); /* get tick */
Expand Down Expand Up @@ -644,7 +644,7 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
LOG_W(_WARNING_NO_RTC);
return -1;
#else
register rt_base_t level;
rt_base_t level;
int second;
rt_tick_t tick;
rt_device_t device;
Expand Down Expand Up @@ -986,7 +986,7 @@ static volatile int8_t _current_timezone = RT_LIBC_DEFAULT_TIMEZONE;

void tz_set(int8_t tz)
{
register rt_base_t level;
rt_base_t level;
level = rt_hw_interrupt_disable();
_current_timezone = tz;
rt_hw_interrupt_enable(level);
Expand Down
10 changes: 5 additions & 5 deletions components/libc/cplusplus/cpp11/atomic_8.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
uint64_t __atomic_load_8(volatile void *ptr, int memorder)
{
volatile uint64_t *val_ptr = (volatile uint64_t *)ptr;
register rt_base_t level;
rt_base_t level;
uint64_t tmp;
level = rt_hw_interrupt_disable();
tmp = *val_ptr;
Expand All @@ -30,7 +30,7 @@ uint64_t __atomic_load_8(volatile void *ptr, int memorder)
void __atomic_store_8(volatile void *ptr, uint64_t val, int memorder)
{
volatile uint64_t *val_ptr = (volatile uint64_t *)ptr;
register rt_base_t level;
rt_base_t level;
level = rt_hw_interrupt_disable();
*val_ptr = val;
rt_hw_interrupt_enable(level);
Expand All @@ -39,7 +39,7 @@ void __atomic_store_8(volatile void *ptr, uint64_t val, int memorder)
uint64_t __atomic_exchange_8(volatile void *ptr, uint64_t val, int memorder)
{
volatile uint64_t *val_ptr = (volatile uint64_t *)ptr;
register rt_base_t level;
rt_base_t level;
uint64_t tmp;
level = rt_hw_interrupt_disable();
tmp = *val_ptr;
Expand All @@ -52,7 +52,7 @@ bool __atomic_compare_exchange_8(volatile void *ptr, volatile void *expected, ui
{
volatile uint64_t *val_ptr = (volatile uint64_t *)ptr;
volatile uint64_t *expected_ptr = (volatile uint64_t *)expected;
register rt_base_t level;
rt_base_t level;
bool exchanged;
level = rt_hw_interrupt_disable();
if (*val_ptr == *expected_ptr)
Expand All @@ -72,7 +72,7 @@ bool __atomic_compare_exchange_8(volatile void *ptr, volatile void *expected, ui
#define __atomic_fetch_op_8(OPNAME, OP) \
uint64_t __atomic_fetch_##OPNAME##_8(volatile void *ptr, uint64_t val, int memorder) {\
volatile uint64_t* val_ptr = (volatile uint64_t*)ptr;\
register rt_base_t level;\
rt_base_t level;\
uint64_t tmp;\
level = rt_hw_interrupt_disable();\
tmp = *val_ptr;\
Expand Down
Loading

0 comments on commit f5b0bfd

Please sign in to comment.