Skip to content

Commit

Permalink
Modify function return value.
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieTx committed Jan 2, 2025
1 parent 41c781d commit a8b5ab7
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions bsp/hc32/tests/test_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int adc_vol_sample(int argc, char **argv)
else
{
rt_kprintf("The chip hasn't the adc unit!\r\n");
return RT_ERROR;
return -RT_ERROR;
}
}

Expand All @@ -120,7 +120,7 @@ static int adc_vol_sample(int argc, char **argv)
if (adc_dev == RT_NULL)
{
rt_kprintf("adc sample run failed! can't find %s device!\r\n", adc_device);
return RT_ERROR;
return -RT_ERROR;
}

#if defined(BSP_ADC1_USING_DMA) || defined(BSP_ADC2_USING_DMA) || defined(BSP_ADC3_USING_DMA)
Expand Down
4 changes: 2 additions & 2 deletions bsp/hc32/tests/test_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ int can_sample(int argc, char **argv)
else
{
rt_kprintf("The chip hasn't the can unit!\r\n");
return RT_ERROR;
return -RT_ERROR;
}
}
else
Expand All @@ -347,7 +347,7 @@ int can_sample(int argc, char **argv)
if (!can_dev)
{
rt_kprintf("find %s failed!\n", can_name);
return RT_ERROR;
return -RT_ERROR;
}

if (can_mutex == RT_NULL)
Expand Down
8 changes: 4 additions & 4 deletions bsp/hc32/tests/test_dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static int dac_vol_sample(int argc, char *argv[])
else
{
rt_kprintf("The chip hasn't the dac unit!\r\n");
return RT_ERROR;
return -RT_ERROR;
}
}

Expand All @@ -59,13 +59,13 @@ static int dac_vol_sample(int argc, char *argv[])
if (dac_dev == RT_NULL)
{
rt_kprintf("dac sample run failed! can't find %s device!\n", dac_device_name);
return RT_ERROR;
return -RT_ERROR;
}

if (RT_EOK != rt_device_control(&dac_dev->parent, RT_DAC_CMD_GET_RESOLUTION, &convertBits))
{
rt_kprintf("dac sample can't read resolution!\n");
return RT_ERROR;
return -RT_ERROR;
}
convertBits = (1 << (rt_uint8_t)convertBits);
for (channel = 1; channel < 3; channel++)
Expand All @@ -79,7 +79,7 @@ static int dac_vol_sample(int argc, char *argv[])
if (value > DAC_MAX_OUTPUT_VALUE)
{
rt_kprintf("invalid dac value!!! \n");
return RT_ERROR;
return -RT_ERROR;
}
}
rt_dac_write(dac_dev, channel, value);
Expand Down
6 changes: 3 additions & 3 deletions bsp/hc32/tests/test_hwtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ static int hwtimer_sample(int argc, char *argv[])
if ((argc != 4) || (rt_strcmp("oneshot", argv[2]) && rt_strcmp("period", argv[2])))
{
_hwtimer_cmd_print_usage();
return RT_ERROR;
return -RT_ERROR;
}

/* 查找定时器设备 */
hw_dev = rt_device_find(argv[1]);
if (hw_dev == RT_NULL)
{
rt_kprintf("hwtimer sample run failed! can't find %s device!\n", argv[1]);
return RT_ERROR;
return -RT_ERROR;
}
else
{
Expand Down Expand Up @@ -116,7 +116,7 @@ static int hwtimer_sample(int argc, char *argv[])
if (rt_device_write(hw_dev, 0, &timeout_s, sizeof(timeout_s)) != sizeof(timeout_s))
{
rt_kprintf("set timeout value failed\n");
return RT_ERROR;
return -RT_ERROR;
}
tick = rt_tick_get();
rt_kprintf("set timeout (%d) ms successful\n", atoi(argv[3]));
Expand Down
6 changes: 3 additions & 3 deletions bsp/hc32/tests/test_pulse_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static int encoder_sample(int argc, char **argv)
if ((argc != 4))
{
_pulse_cmd_print_usage();
return RT_ERROR;
return -RT_ERROR;
}

rt_pin_mode(TEST_IO_A_PIN, PIN_MODE_OUTPUT);
Expand All @@ -170,7 +170,7 @@ static int encoder_sample(int argc, char **argv)
{
rt_kprintf("encoder_sample run failed! can't find %s device!\n", argv[1]);
_pulse_cmd_print_usage();
return RT_ERROR;
return -RT_ERROR;
}
rt_device_open(pulse_encoder_dev, RT_DEVICE_OFLAG_RDONLY);
rt_device_control(pulse_encoder_dev, PULSE_ENCODER_CMD_CLEAR_COUNT, RT_NULL);
Expand All @@ -188,7 +188,7 @@ static int encoder_sample(int argc, char **argv)
rt_kprintf("**************Self-test failed**************\n");
rt_device_close(pulse_encoder_dev);
_pulse_cmd_print_usage();
return RT_ERROR;
return -RT_ERROR;
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions bsp/hc32/tests/test_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ static rt_int32_t pwm_sample(int argc, char *argv[])

if (argc != 2)
{
return RT_ERROR;
return -RT_ERROR;
}

pwm_dev = (struct rt_device_pwm *)rt_device_find(argv[1]);
if (pwm_dev == RT_NULL)
{
rt_kprintf("pwm sample run failed! can't find %s device!\n", argv[1]);
return RT_ERROR;
return -RT_ERROR;
}

rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, period, pulse);
Expand Down
22 changes: 11 additions & 11 deletions bsp/hc32/tests/test_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static int rtc_sample(int argc, char *argv[])
rt_kprintf("\'8\': dump all alarm \n");
rt_kprintf("\'9\': delete all alarm \n");
#endif /* RT_USING_ALARM */
return RT_ERROR;
return -RT_ERROR;
}

idx = *(argv[1]) - '0';
Expand All @@ -110,12 +110,12 @@ static int rtc_sample(int argc, char *argv[])
if (!rtc_dev)
{
rt_kprintf("find %s failed\n", SAMPLE_RTC_NAME);
return RT_ERROR;
return -RT_ERROR;
}
if (RT_EOK != rt_device_open(rtc_dev, RT_NULL))
{
rt_kprintf("failed to open %s\n", SAMPLE_RTC_NAME);
return RT_ERROR;
return -RT_ERROR;
}
rt_kprintf("rtc opened\n");
break;
Expand All @@ -124,7 +124,7 @@ static int rtc_sample(int argc, char *argv[])
if (argc < 3)
{
rt_kprintf("unsurpported command\n");
return RT_ERROR;
return -RT_ERROR;
}
temp1 = ((argv[2][0] - '0') * 10) + \
(argv[2][1] - '0');
Expand All @@ -135,7 +135,7 @@ static int rtc_sample(int argc, char *argv[])
if (RT_EOK != set_time(temp1, temp2, temp3))
{
rt_kprintf("set RTC time failed\n");
return RT_ERROR;
return -RT_ERROR;
}
rt_kprintf("\nset RTC time as %2d:%2d:%2d\n", temp1, temp2, temp3);
break;
Expand All @@ -152,7 +152,7 @@ static int rtc_sample(int argc, char *argv[])
if (RT_EOK != set_date(temp1, temp2, temp3))
{
rt_kprintf("failed to set date for %s\n", SAMPLE_RTC_NAME);
return RT_ERROR;
return -RT_ERROR;
}
rt_kprintf("\nset RTC date as %4d-%2d-%2d\n", temp1, temp2, temp3);
break;
Expand Down Expand Up @@ -190,7 +190,7 @@ static int rtc_sample(int argc, char *argv[])
if (RT_NULL == ptr_alarm)
{
rt_kprintf("failed to create rtc alarm\n");
return RT_ERROR;
return -RT_ERROR;
}
callback_counter = 2;
++alarm_idx;
Expand All @@ -200,23 +200,23 @@ static int rtc_sample(int argc, char *argv[])
if (RT_EOK != rt_alarm_start(ptr_alarm))
{
rt_kprintf("failed to start rtc alarm\n");
return RT_ERROR;
return -RT_ERROR;
}
rt_kprintf("rtc alarm started\n");
break;
case CMD_STOP_ALARM:
if (RT_EOK != rt_alarm_stop(ptr_alarm))
{
rt_kprintf("failed to stop rtc alarm\n");
return RT_ERROR;
return -RT_ERROR;
}
rt_kprintf("rtc alarm stopped\n");
break;
case CMD_CTRL_ALARM:
if (argc < 3)
{
rt_kprintf("unkown para to control rtc alarm\n");
return RT_ERROR;
return -RT_ERROR;
}
switch (argv[2][0])
{
Expand Down Expand Up @@ -253,7 +253,7 @@ static int rtc_sample(int argc, char *argv[])
if (RT_EOK != rt_device_close(rtc_dev))
{
rt_kprintf("failed to close RTC\n");
return RT_ERROR;
return -RT_ERROR;
}
rt_kprintf("unkown rtc command, rtc closed \n");
break;
Expand Down
4 changes: 2 additions & 2 deletions bsp/hc32/tests/test_soft_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int sw_i2c_sample(int argc, char *argv[])
rt_kprintf("sw_i2c_sample %d: oled ssd1306 init\n", SSD1306_CMD_INIT);
rt_kprintf("sw_i2c_sample %d: write ssd1306 \n", SSD1306_CMD_DISPLAY);
rt_kprintf("sw_i2c_sample %d: turn off ssd1306\n", SSD1306_CMD_DEINIT);
return RT_ERROR;
return -RT_ERROR;
}

switch (*argv[1] - '0')
Expand All @@ -150,7 +150,7 @@ static int sw_i2c_sample(int argc, char *argv[])
if (NULL == rt_i2c_dev)
{
rt_kprintf("failed to find i2c device %s\n", SW_I2C_NAME);
return RT_ERROR;
return -RT_ERROR;
}
break;
/* communicate with eeprom to soft i2c read function */
Expand Down
8 changes: 4 additions & 4 deletions bsp/hc32/tests/test_uart_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ int uart_sample_v1(int argc, char *argv[])
else
{
rt_kprintf("argc error!\n");
return RT_ERROR;
return -RT_ERROR;
}

/* 查找系统中的串口设备 */
serial = rt_device_find(uart_name);
if (!serial)
{
rt_kprintf("find %s failed!\n", uart_name);
return RT_ERROR;
return -RT_ERROR;
}

/* modify configure */
Expand Down Expand Up @@ -256,7 +256,7 @@ int uart_sample_v1(int argc, char *argv[])
else
{
rt_kprintf("communication mode error, please input cmd: uart_sample_v1 %s int or uart_sample_v1 uartx dma!\n", uart_name);
return RT_ERROR;
return -RT_ERROR;
}

if (thread != RT_NULL)
Expand All @@ -265,7 +265,7 @@ int uart_sample_v1(int argc, char *argv[])
}
else
{
ret = RT_ERROR;
ret = -RT_ERROR;
}

return ret;
Expand Down
8 changes: 4 additions & 4 deletions bsp/hc32/tests/test_uart_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ int uart_sample_v2(int argc, char *argv[])
else
{
rt_kprintf("argc error!\n");
return RT_ERROR;
return -RT_ERROR;
}

/* 查找串口设备 */
serial = rt_device_find(uart_name);
if (!serial)
{
rt_kprintf("find %s failed!\n", uart_name);
return RT_ERROR;
return -RT_ERROR;
}

/* modify configure */
Expand Down Expand Up @@ -277,7 +277,7 @@ int uart_sample_v2(int argc, char *argv[])
else
{
rt_kprintf("communication mode error, please input cmd: uart_sample_v2 %s int or uart_sample_v1 uartx dma!\n", uart_name);
return RT_ERROR;
return -RT_ERROR;
}

if (thread != RT_NULL)
Expand All @@ -286,7 +286,7 @@ int uart_sample_v2(int argc, char *argv[])
}
else
{
ret = RT_ERROR;
ret = -RT_ERROR;
}

return ret;
Expand Down
10 changes: 5 additions & 5 deletions bsp/hc32/tests/test_usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static int cdc_sample(void)
if (cdc_dev == RT_NULL)
{
rt_kprintf("cdc sample run failed! can't find %s device!\n", USBD_DEV_NAME);
return RT_ERROR;
return -RT_ERROR;
}

/* 以读写方式打开设备 */
Expand All @@ -74,7 +74,7 @@ static int cdc_sample(void)
if (rt_device_write(cdc_dev, 0, str_write, sizeof(str_write)) != sizeof(str_write))
{
rt_kprintf("send test message failed\n");
return RT_ERROR;
return -RT_ERROR;
}
/* 延时1000ms */
rt_thread_mdelay(1000);
Expand Down Expand Up @@ -159,7 +159,7 @@ static int rt_hw_spi_flash_with_sfud_init(void)
rt_hw_spi_flash_reset(SPI_FLASH_DEVICE_NAME);
if (RT_NULL == rt_sfud_flash_probe(SPI_FLASH_CHIP, SPI_FLASH_DEVICE_NAME))
{
return RT_ERROR;
return -RT_ERROR;
}
}

Expand Down Expand Up @@ -211,7 +211,7 @@ static int hid_sample(void)
if (hid_dev == RT_NULL)
{
rt_kprintf("hid sample run failed! can't find %s device!\n", USBD_DEV_NAME);
return RT_ERROR;
return -RT_ERROR;
}

/* 以收中断方式打开设备 */
Expand Down Expand Up @@ -296,7 +296,7 @@ static int winusb_sample(void)
if (winusb_dev == RT_NULL)
{
rt_kprintf("winusb sample run failed! can't find %s device!\n", WINUSB_DEV_NAME);
return RT_ERROR;
return -RT_ERROR;
}

/* 以读写方式打开设备 */
Expand Down
6 changes: 3 additions & 3 deletions bsp/hc32/tests/test_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ static int wdt_sample(int argc, char *argv[])
if (!wdg_dev)
{
rt_kprintf("find %s failed!\n", WDT_DEVICE_NAME);
return RT_ERROR;
return -RT_ERROR;
}

ret = rt_device_init(wdg_dev);
if (ret != RT_EOK)
{
rt_kprintf("init %s failed!\n", WDT_DEVICE_NAME);
return RT_ERROR;
return -RT_ERROR;
}

/* Set timeout (Unit:S) */
ret = rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout);
if (ret != RT_EOK)
{
rt_kprintf("set %s timeout failed!\n", WDT_DEVICE_NAME);
return RT_ERROR;
return -RT_ERROR;
}

/* Get the time when it real effective */
Expand Down

0 comments on commit a8b5ab7

Please sign in to comment.