Compare commits
No commits in common. "a55ef6efcc5d6d8ddbae80040b4ced986304fa01" and "2b0227798c5493c04bf1bf439aa85a62409e3786" have entirely different histories.
a55ef6efcc
...
2b0227798c
6
.config
6
.config
@ -201,7 +201,7 @@ CONFIG_RT_USING_I2C_BITOPS=y
|
|||||||
# CONFIG_RT_I2C_BITOPS_DEBUG is not set
|
# CONFIG_RT_I2C_BITOPS_DEBUG is not set
|
||||||
# CONFIG_RT_USING_SOFT_I2C is not set
|
# CONFIG_RT_USING_SOFT_I2C is not set
|
||||||
# CONFIG_RT_USING_PHY is not set
|
# CONFIG_RT_USING_PHY is not set
|
||||||
CONFIG_RT_USING_ADC=y
|
# CONFIG_RT_USING_ADC is not set
|
||||||
# CONFIG_RT_USING_DAC is not set
|
# CONFIG_RT_USING_DAC is not set
|
||||||
# CONFIG_RT_USING_NULL is not set
|
# CONFIG_RT_USING_NULL is not set
|
||||||
# CONFIG_RT_USING_ZERO is not set
|
# CONFIG_RT_USING_ZERO is not set
|
||||||
@ -1691,9 +1691,7 @@ CONFIG_BSP_USING_SPI=y
|
|||||||
CONFIG_BSP_USING_SPI2=y
|
CONFIG_BSP_USING_SPI2=y
|
||||||
# CONFIG_BSP_SPI2_TX_USING_DMA is not set
|
# CONFIG_BSP_SPI2_TX_USING_DMA is not set
|
||||||
# CONFIG_BSP_SPI2_RX_USING_DMA is not set
|
# CONFIG_BSP_SPI2_RX_USING_DMA is not set
|
||||||
CONFIG_BSP_USING_ADC=y
|
# CONFIG_BSP_USING_ADC is not set
|
||||||
CONFIG_BSP_USING_ADC1=y
|
|
||||||
# CONFIG_BSP_USING_ADC3 is not set
|
|
||||||
CONFIG_BSP_USING_I2C=y
|
CONFIG_BSP_USING_I2C=y
|
||||||
# CONFIG_BSP_USING_I2C1 is not set
|
# CONFIG_BSP_USING_I2C1 is not set
|
||||||
CONFIG_BSP_USING_I2C2=y
|
CONFIG_BSP_USING_I2C2=y
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
#include "indicator_led.h"
|
#include "indicator_led.h"
|
||||||
#include "rtdevice.h"
|
|
||||||
|
|
||||||
#define ADC_DEV_NAME "adc1" /* ADC 设备名称 */
|
|
||||||
#define ADC_DEV_CHANNEL 5 /* ADC 通道 */
|
|
||||||
#define REFER_VOLTAGE 330 /* 参考电压 3.3V,数据精度乘以100保留2位小数*/
|
|
||||||
#define CONVERT_BITS (1 << 12) /* 转换位数为12位 */
|
|
||||||
|
|
||||||
#define LED_NUM 24 // LED灯珠个数
|
#define LED_NUM 24 // LED灯珠个数
|
||||||
|
|
||||||
@ -26,15 +20,15 @@ const RGBColor_TypeDef LED_ON = {255, 255, 255};
|
|||||||
void LED_BreathTurn(uint8_t LedBreath_state)
|
void LED_BreathTurn(uint8_t LedBreath_state)
|
||||||
{
|
{
|
||||||
LED_Breath_State = LedBreath_state;
|
LED_Breath_State = LedBreath_state;
|
||||||
// if (LedBreath_state == LED_BREATH_OFF)
|
if (LedBreath_state == LED_BREATH_OFF)
|
||||||
// {
|
{
|
||||||
// // rt_thread_suspend(led_breath_thread);
|
// rt_thread_suspend(led_breath_thread);
|
||||||
// LED_SetMore(LED_BREATH_ID(1), LED_BREATH_ID(12), LED_OFF);
|
LED_SetMore(LED_BREATH_ID(1), LED_BREATH_ID(12), LED_OFF);
|
||||||
// }
|
}
|
||||||
// else if (LedBreath_state == LED_BREATH_ON)
|
else if (LedBreath_state == LED_BREATH_ON)
|
||||||
// {
|
{
|
||||||
// // rt_thread_resume(led_breath_thread);
|
// rt_thread_resume(led_breath_thread);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 设置特定LED的颜色或开关
|
* @brief 设置特定LED的颜色或开关
|
||||||
@ -154,63 +148,19 @@ void led_breath_entry(void *parameter)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
RGB_Reflash();
|
RGB_Reflash();
|
||||||
rt_thread_delay(40);
|
rt_thread_mdelay(500);
|
||||||
}
|
}
|
||||||
count = (count + 1) % 3;
|
count = (count + 1) % 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BORAD_NOT_CORRECT 25
|
// MSH_CMD_EXPORT_ALIAS(led_breath_thread,BREATH, "BREATH LIGHT");
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 检测一下当前接入的是否是正确的板
|
|
||||||
*/
|
|
||||||
static int borad_check(void)
|
|
||||||
{
|
|
||||||
rt_adc_device_t adc_dev;
|
|
||||||
rt_uint32_t value, vol;
|
|
||||||
rt_err_t ret = RT_EOK;
|
|
||||||
|
|
||||||
/* 查找设备 */
|
|
||||||
adc_dev = (rt_adc_device_t)rt_device_find(ADC_DEV_NAME);
|
|
||||||
if (adc_dev == RT_NULL)
|
|
||||||
{
|
|
||||||
rt_kprintf("adc sample run failed! can't find %s device!\n", ADC_DEV_NAME);
|
|
||||||
return RT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 使能设备 */
|
|
||||||
ret = rt_adc_enable(adc_dev, ADC_DEV_CHANNEL);
|
|
||||||
|
|
||||||
/* 读取采样值 */
|
|
||||||
value = rt_adc_read(adc_dev, ADC_DEV_CHANNEL);
|
|
||||||
|
|
||||||
/* 转换为对应电压值 */
|
|
||||||
vol = value * REFER_VOLTAGE / CONVERT_BITS;
|
|
||||||
if(vol>=0.25*100)
|
|
||||||
{
|
|
||||||
rt_kprintf("NOT correct borad!\n");
|
|
||||||
rt_kprintf("the value is :%d \n", value);
|
|
||||||
rt_kprintf("the voltage is :%d.%02d \n", vol / 100, vol % 100);
|
|
||||||
return BORAD_NOT_CORRECT;
|
|
||||||
}
|
|
||||||
/* 关闭通道 */
|
|
||||||
ret = rt_adc_disable(adc_dev, ADC_DEV_CHANNEL);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/* 导出到 msh 命令列表中 */
|
|
||||||
MSH_CMD_EXPORT(borad_check, adc voltage convert sample);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief LED的初始化
|
* @brief LED的初始化
|
||||||
*/
|
*/
|
||||||
int led_init(void)
|
int led_init(void)
|
||||||
{
|
{
|
||||||
if (borad_check()==BORAD_NOT_CORRECT)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
led_blink_thread = rt_thread_create("led blink control thread", led_blink_entry, RT_NULL, 1024, 20, 20);
|
led_blink_thread = rt_thread_create("led blink control thread", led_blink_entry, RT_NULL, 1024, 20, 20);
|
||||||
if (led_blink_thread == RT_NULL)
|
if (led_blink_thread == RT_NULL)
|
||||||
{
|
{
|
||||||
|
@ -619,6 +619,8 @@ void my_project(void)
|
|||||||
|
|
||||||
serial_init();
|
serial_init();
|
||||||
|
|
||||||
led_init();
|
led_blink_init();
|
||||||
|
|
||||||
|
led_breath_init();
|
||||||
}
|
}
|
||||||
MSH_CMD_EXPORT_ALIAS(my_project, myproject, run my project);
|
MSH_CMD_EXPORT_ALIAS(my_project, myproject, run my project);
|
@ -133,7 +133,6 @@
|
|||||||
#define RT_SERIAL_RB_BUFSZ 64
|
#define RT_SERIAL_RB_BUFSZ 64
|
||||||
#define RT_USING_I2C
|
#define RT_USING_I2C
|
||||||
#define RT_USING_I2C_BITOPS
|
#define RT_USING_I2C_BITOPS
|
||||||
#define RT_USING_ADC
|
|
||||||
#define RT_USING_PWM
|
#define RT_USING_PWM
|
||||||
#define RT_USING_RTC
|
#define RT_USING_RTC
|
||||||
#define RT_USING_SOFT_RTC
|
#define RT_USING_SOFT_RTC
|
||||||
@ -656,8 +655,6 @@
|
|||||||
#define BSP_USING_ON_CHIP_FLASH
|
#define BSP_USING_ON_CHIP_FLASH
|
||||||
#define BSP_USING_SPI
|
#define BSP_USING_SPI
|
||||||
#define BSP_USING_SPI2
|
#define BSP_USING_SPI2
|
||||||
#define BSP_USING_ADC
|
|
||||||
#define BSP_USING_ADC1
|
|
||||||
#define BSP_USING_I2C
|
#define BSP_USING_I2C
|
||||||
#define BSP_USING_I2C2
|
#define BSP_USING_I2C2
|
||||||
#define BSP_I2C2_SCL_PIN 81
|
#define BSP_I2C2_SCL_PIN 81
|
||||||
|
Loading…
x
Reference in New Issue
Block a user