Merge pull request #4465 from mysterywolf/nrf5152
[nrf5x] auto formatted
This commit is contained in:
commit
95c0569b33
|
@ -14,9 +14,9 @@
|
||||||
|
|
||||||
// <o> Internal SRAM memory size[Kbytes] <16 or 32>
|
// <o> Internal SRAM memory size[Kbytes] <16 or 32>
|
||||||
// <i>Default: 16
|
// <i>Default: 16
|
||||||
#define NRF_SRAM_BEGIN (0x20000000)
|
#define NRF_SRAM_BEGIN (0x20000000)
|
||||||
#define NRF_SRAM_SIZE (16 * 1024)
|
#define NRF_SRAM_SIZE (16 * 1024)
|
||||||
#define NRF_SRAM_END (NRF_SRAM_BEGIN + NRF_SRAM_SIZE)
|
#define NRF_SRAM_END (NRF_SRAM_BEGIN + NRF_SRAM_SIZE)
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -189,10 +189,10 @@ void rt_hw_uart_init(void)
|
||||||
rt_ringbuffer_init(&(uart->rx_rb), rx_buffer, sizeof(rx_buffer));
|
rt_ringbuffer_init(&(uart->rx_rb), rx_buffer, sizeof(rx_buffer));
|
||||||
|
|
||||||
/* device interface */
|
/* device interface */
|
||||||
uart->parent.init = rt_uart_init;
|
uart->parent.init = rt_uart_init;
|
||||||
uart->parent.open = rt_uart_open;
|
uart->parent.open = rt_uart_open;
|
||||||
uart->parent.close = rt_uart_close;
|
uart->parent.close = rt_uart_close;
|
||||||
uart->parent.read = rt_uart_read;
|
uart->parent.read = rt_uart_read;
|
||||||
uart->parent.write = rt_uart_write;
|
uart->parent.write = rt_uart_write;
|
||||||
uart->parent.control = RT_NULL;
|
uart->parent.control = RT_NULL;
|
||||||
uart->parent.user_data = RT_NULL;
|
uart->parent.user_data = RT_NULL;
|
||||||
|
|
|
@ -3,16 +3,16 @@
|
||||||
#define __RTTHREAD_CFG_H__
|
#define __RTTHREAD_CFG_H__
|
||||||
|
|
||||||
/* RT_NAME_MAX*/
|
/* RT_NAME_MAX*/
|
||||||
#define RT_NAME_MAX 6
|
#define RT_NAME_MAX 6
|
||||||
|
|
||||||
/* RT_ALIGN_SIZE*/
|
/* RT_ALIGN_SIZE*/
|
||||||
#define RT_ALIGN_SIZE 4
|
#define RT_ALIGN_SIZE 4
|
||||||
|
|
||||||
/* PRIORITY_MAX */
|
/* PRIORITY_MAX */
|
||||||
#define RT_THREAD_PRIORITY_MAX 8
|
#define RT_THREAD_PRIORITY_MAX 8
|
||||||
|
|
||||||
/* Tick per Second */
|
/* Tick per Second */
|
||||||
#define RT_TICK_PER_SECOND 100
|
#define RT_TICK_PER_SECOND 100
|
||||||
|
|
||||||
/* SECTION: RT_DEBUG */
|
/* SECTION: RT_DEBUG */
|
||||||
/* Thread Debug */
|
/* Thread Debug */
|
||||||
|
@ -24,13 +24,13 @@
|
||||||
/* Using Hook */
|
/* Using Hook */
|
||||||
#define RT_USING_HOOK
|
#define RT_USING_HOOK
|
||||||
|
|
||||||
#define IDLE_THREAD_STACK_SIZE 512
|
#define IDLE_THREAD_STACK_SIZE 512
|
||||||
|
|
||||||
/* Using Software Timer */
|
/* Using Software Timer */
|
||||||
/* #define RT_USING_TIMER_SOFT */
|
/* #define RT_USING_TIMER_SOFT */
|
||||||
#define RT_TIMER_THREAD_PRIO 4
|
#define RT_TIMER_THREAD_PRIO 4
|
||||||
#define RT_TIMER_THREAD_STACK_SIZE 512
|
#define RT_TIMER_THREAD_STACK_SIZE 512
|
||||||
#define RT_TIMER_TICK_PER_SECOND 100
|
#define RT_TIMER_TICK_PER_SECOND 100
|
||||||
|
|
||||||
/* SECTION: IPC */
|
/* SECTION: IPC */
|
||||||
/* Using Semaphore*/
|
/* Using Semaphore*/
|
||||||
|
@ -74,9 +74,9 @@
|
||||||
/* SECTION: Console options */
|
/* SECTION: Console options */
|
||||||
#define RT_USING_CONSOLE
|
#define RT_USING_CONSOLE
|
||||||
/* the buffer size of console*/
|
/* the buffer size of console*/
|
||||||
#define RT_CONSOLEBUF_SIZE 128
|
#define RT_CONSOLEBUF_SIZE 128
|
||||||
// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart1" />
|
// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart1" />
|
||||||
#define RT_CONSOLE_DEVICE_NAME "uart0"
|
#define RT_CONSOLE_DEVICE_NAME "uart0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@
|
||||||
#define RT_USING_FINSH
|
#define RT_USING_FINSH
|
||||||
/* configure finsh parameters */
|
/* configure finsh parameters */
|
||||||
#define FINSH_THREAD_PRIORITY 6
|
#define FINSH_THREAD_PRIORITY 6
|
||||||
#define FINSH_THREAD_STACK_SIZE 512
|
#define FINSH_THREAD_STACK_SIZE 512
|
||||||
#define FINSH_HISTORY_LINES 1
|
#define FINSH_HISTORY_LINES 1
|
||||||
/* Using symbol table */
|
/* Using symbol table */
|
||||||
#define FINSH_USING_SYMTAB
|
#define FINSH_USING_SYMTAB
|
||||||
#define FINSH_USING_DESCRIPTION
|
#define FINSH_USING_DESCRIPTION
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -31,7 +31,7 @@ static void nrf5x_saadc_event_hdr(nrfx_saadc_evt_t const * p_event)
|
||||||
j ++;
|
j ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results.done = 1;
|
results.done = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,22 +72,22 @@ static void set_channels(drv_nrfx_saadc_channel_t * channel)
|
||||||
|
|
||||||
/* channel: 0-7 */
|
/* channel: 0-7 */
|
||||||
static rt_err_t nrf5x_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
|
static rt_err_t nrf5x_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
|
||||||
{
|
{
|
||||||
nrfx_err_t err_code = NRFX_SUCCESS;
|
nrfx_err_t err_code = NRFX_SUCCESS;
|
||||||
uint8_t i,j;
|
uint8_t i,j;
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
RT_ASSERT(device != RT_NULL);
|
RT_ASSERT(device != RT_NULL);
|
||||||
RT_ASSERT(device->parent.user_data != RT_NULL);
|
RT_ASSERT(device->parent.user_data != RT_NULL);
|
||||||
|
|
||||||
drv_nrfx_saadc_channel_t * drv_channel_config = NULL;
|
drv_nrfx_saadc_channel_t * drv_channel_config = NULL;
|
||||||
drv_channel_config = (drv_nrfx_saadc_channel_t *)device->parent.user_data;
|
drv_channel_config = (drv_nrfx_saadc_channel_t *)device->parent.user_data;
|
||||||
|
|
||||||
set_channels(drv_channel_config);
|
set_channels(drv_channel_config);
|
||||||
|
|
||||||
nrfx_saadc_channel_t channels_cache[results.channel_count];
|
nrfx_saadc_channel_t channels_cache[results.channel_count];
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
for(i = 0; i < 8; i++)
|
for(i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
|
@ -97,20 +97,20 @@ static rt_err_t nrf5x_adc_enabled(struct rt_adc_device *device, rt_uint32_t chan
|
||||||
j ++;
|
j ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err_code = nrfx_saadc_channels_config(channels_cache,results.channel_count);
|
err_code = nrfx_saadc_channels_config(channels_cache,results.channel_count);
|
||||||
|
|
||||||
err_code = nrfx_saadc_simple_mode_set(get_channels_mask(),
|
err_code = nrfx_saadc_simple_mode_set(get_channels_mask(),
|
||||||
NRF_SAADC_RESOLUTION_12BIT,
|
NRF_SAADC_RESOLUTION_12BIT,
|
||||||
NRF_SAADC_OVERSAMPLE_DISABLED,
|
NRF_SAADC_OVERSAMPLE_DISABLED,
|
||||||
nrf5x_saadc_event_hdr);
|
nrf5x_saadc_event_hdr);
|
||||||
|
|
||||||
err_code = nrfx_saadc_buffer_set(result_buff_cache, results.channel_count);
|
err_code = nrfx_saadc_buffer_set(result_buff_cache, results.channel_count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
results.channels[channel].channel_index = 0xff;
|
results.channels[channel].channel_index = 0xff;
|
||||||
|
|
||||||
results.channel_count = 0;
|
results.channel_count = 0;
|
||||||
for(i = 0; i < 8; i++)
|
for(i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
|
@ -119,7 +119,7 @@ static rt_err_t nrf5x_adc_enabled(struct rt_adc_device *device, rt_uint32_t chan
|
||||||
results.channel_count ++;
|
results.channel_count ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(results.channel_count == 0)
|
if(results.channel_count == 0)
|
||||||
{
|
{
|
||||||
nrfx_saadc_channel_t channels_cache[1];
|
nrfx_saadc_channel_t channels_cache[1];
|
||||||
|
@ -129,7 +129,7 @@ static rt_err_t nrf5x_adc_enabled(struct rt_adc_device *device, rt_uint32_t chan
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nrfx_saadc_channel_t channels_cache[results.channel_count];
|
nrfx_saadc_channel_t channels_cache[results.channel_count];
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
for(i = 0; i < 8; i++)
|
for(i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
|
@ -139,25 +139,25 @@ static rt_err_t nrf5x_adc_enabled(struct rt_adc_device *device, rt_uint32_t chan
|
||||||
j ++;
|
j ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err_code = nrfx_saadc_channels_config(channels_cache,results.channel_count);
|
err_code = nrfx_saadc_channels_config(channels_cache,results.channel_count);
|
||||||
|
|
||||||
err_code = nrfx_saadc_simple_mode_set(get_channels_mask(),
|
err_code = nrfx_saadc_simple_mode_set(get_channels_mask(),
|
||||||
NRF_SAADC_RESOLUTION_12BIT,
|
NRF_SAADC_RESOLUTION_12BIT,
|
||||||
NRF_SAADC_OVERSAMPLE_DISABLED,
|
NRF_SAADC_OVERSAMPLE_DISABLED,
|
||||||
nrf5x_saadc_event_hdr);
|
nrf5x_saadc_event_hdr);
|
||||||
|
|
||||||
err_code = nrfx_saadc_buffer_set(result_buff_cache, results.channel_count);
|
err_code = nrfx_saadc_buffer_set(result_buff_cache, results.channel_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static rt_err_t nrf5x_get_adc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
|
static rt_err_t nrf5x_get_adc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
|
||||||
{
|
{
|
||||||
nrfx_err_t err_code = NRFX_SUCCESS;
|
nrfx_err_t err_code = NRFX_SUCCESS;
|
||||||
|
|
||||||
if (results.channels[channel].channel_index != 0xff)
|
if (results.channels[channel].channel_index != 0xff)
|
||||||
{
|
{
|
||||||
results.done = 0;
|
results.done = 0;
|
||||||
|
@ -169,7 +169,7 @@ static rt_err_t nrf5x_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
|
||||||
* value = results.result_buffer[channel];
|
* value = results.result_buffer[channel];
|
||||||
results.done = 0;
|
results.done = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ int rt_hw_adc_init(void)
|
||||||
int result = RT_EOK;
|
int result = RT_EOK;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
char name_buf[6] = ADC_NAME;
|
char name_buf[6] = ADC_NAME;
|
||||||
|
|
||||||
for(i = 0; i < 8; i++)
|
for(i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
results.channels[i].channel_index = 0xff;
|
results.channels[i].channel_index = 0xff;
|
||||||
|
@ -192,7 +192,7 @@ int rt_hw_adc_init(void)
|
||||||
results.channel_count = 0;
|
results.channel_count = 0;
|
||||||
results.done = 0;
|
results.done = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initializing SAADC interrupt priority */
|
/* initializing SAADC interrupt priority */
|
||||||
if (nrfx_saadc_init(NRFX_SAADC_CONFIG_IRQ_PRIORITY) != NRFX_SUCCESS)
|
if (nrfx_saadc_init(NRFX_SAADC_CONFIG_IRQ_PRIORITY) != NRFX_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -236,43 +236,43 @@ INIT_BOARD_EXPORT(rt_hw_adc_init);
|
||||||
void saadc_sample(void)
|
void saadc_sample(void)
|
||||||
{
|
{
|
||||||
drv_nrfx_saadc_channel_t channel_config;
|
drv_nrfx_saadc_channel_t channel_config;
|
||||||
rt_uint32_t result;
|
rt_uint32_t result;
|
||||||
|
|
||||||
rt_adc_device_t adc_dev;
|
rt_adc_device_t adc_dev;
|
||||||
adc_dev = (rt_adc_device_t)rt_device_find(ADC_NAME);
|
adc_dev = (rt_adc_device_t)rt_device_find(ADC_NAME);
|
||||||
adc_dev->parent.user_data = &channel_config;
|
adc_dev->parent.user_data = &channel_config;
|
||||||
|
|
||||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
||||||
.pin_p = SAMPLE_ADC_AIN1,
|
.pin_p = SAMPLE_ADC_AIN1,
|
||||||
.pin_n = SAMPLE_ADC_AIN_NC,
|
.pin_n = SAMPLE_ADC_AIN_NC,
|
||||||
.channel_num = SAMPLE_ADC_CHANNEL_0};
|
.channel_num = SAMPLE_ADC_CHANNEL_0};
|
||||||
rt_adc_enable(adc_dev, channel_config.channel_num);
|
rt_adc_enable(adc_dev, channel_config.channel_num);
|
||||||
|
|
||||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
||||||
.pin_p = SAMPLE_ADC_AIN2,
|
.pin_p = SAMPLE_ADC_AIN2,
|
||||||
.pin_n = SAMPLE_ADC_AIN_NC,
|
.pin_n = SAMPLE_ADC_AIN_NC,
|
||||||
.channel_num = SAMPLE_ADC_CHANNEL_1};
|
.channel_num = SAMPLE_ADC_CHANNEL_1};
|
||||||
rt_adc_enable(adc_dev, channel_config.channel_num);
|
rt_adc_enable(adc_dev, channel_config.channel_num);
|
||||||
|
|
||||||
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
channel_config = (drv_nrfx_saadc_channel_t){.mode = SAMPLE_ADC_MODE_SINGLE_ENDED,
|
||||||
.pin_p = SAMPLE_ADC_AIN7,
|
.pin_p = SAMPLE_ADC_AIN7,
|
||||||
.pin_n = SAMPLE_ADC_AIN_NC,
|
.pin_n = SAMPLE_ADC_AIN_NC,
|
||||||
.channel_num = SAMPLE_ADC_CHANNEL_5};
|
.channel_num = SAMPLE_ADC_CHANNEL_5};
|
||||||
rt_adc_enable(adc_dev, channel_config.channel_num);
|
rt_adc_enable(adc_dev, channel_config.channel_num);
|
||||||
|
|
||||||
int count = 1;
|
int count = 1;
|
||||||
while(count++)
|
while(count++)
|
||||||
{
|
{
|
||||||
result = rt_adc_read(adc_dev, 0);
|
result = rt_adc_read(adc_dev, 0);
|
||||||
rt_kprintf("saadc channel 0 value = %d, ",result);
|
rt_kprintf("saadc channel 0 value = %d, ",result);
|
||||||
|
|
||||||
result = rt_adc_read(adc_dev, 1);
|
result = rt_adc_read(adc_dev, 1);
|
||||||
rt_kprintf("saadc channel 1 value = %d, ",result);
|
rt_kprintf("saadc channel 1 value = %d, ",result);
|
||||||
|
|
||||||
result = rt_adc_read(adc_dev, 5);
|
result = rt_adc_read(adc_dev, 5);
|
||||||
rt_kprintf("saadc channel 5 value = %d",result);
|
rt_kprintf("saadc channel 5 value = %d",result);
|
||||||
|
|
||||||
rt_kprintf("\r\n");
|
rt_kprintf("\r\n");
|
||||||
rt_thread_mdelay(1000);
|
rt_thread_mdelay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2020-08-18 guohp1128 the first version
|
* 2020-08-18 guohp1128 the first version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __DRV_ADC_H__
|
#ifndef __DRV_ADC_H__
|
||||||
#define __DRV_ADC_H__
|
#define __DRV_ADC_H__
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
#define ADC_NAME "adc"
|
#define ADC_NAME "adc"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
previous definition in application
|
previous definition in application
|
||||||
|
|
||||||
set single-ended mode or differential mode.
|
set single-ended mode or differential mode.
|
||||||
selection ADC input pin, and config the number of Channel.
|
selection ADC input pin, and config the number of Channel.
|
||||||
|
|
||||||
mode: 0 single-ended mode,1 differential mode
|
mode: 0 single-ended mode,1 differential mode
|
||||||
pin_p: 0-7
|
pin_p: 0-7
|
||||||
pin_n: 0-7,if single-ended mode, pin_n invalid
|
pin_n: 0-7,if single-ended mode, pin_n invalid
|
||||||
|
@ -40,9 +40,9 @@ typedef struct
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
nrfx_saadc_channel_t channels[8];
|
nrfx_saadc_channel_t channels[8];
|
||||||
uint8_t channel_count;
|
uint8_t channel_count;
|
||||||
nrf_saadc_value_t result_buffer[8];
|
nrf_saadc_value_t result_buffer[8];
|
||||||
uint8_t done;
|
uint8_t done;
|
||||||
} drv_nrfx_saadc_result_t;
|
} drv_nrfx_saadc_result_t;
|
||||||
|
|
||||||
#endif /* __DRV_ADC_H__ */
|
#endif /* __DRV_ADC_H__ */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#ifdef RT_USING_PIN
|
#ifdef RT_USING_PIN
|
||||||
|
|
||||||
static const struct pin_index pins[] =
|
static const struct pin_index pins[] =
|
||||||
{
|
{
|
||||||
__NRF5X_PIN(0 , 0, 0 ),
|
__NRF5X_PIN(0 , 0, 0 ),
|
||||||
__NRF5X_PIN(1 , 0, 1 ),
|
__NRF5X_PIN(1 , 0, 1 ),
|
||||||
|
@ -46,7 +46,7 @@ static const struct pin_index pins[] =
|
||||||
__NRF5X_PIN(29, 0, 29),
|
__NRF5X_PIN(29, 0, 29),
|
||||||
__NRF5X_PIN(30, 0, 30),
|
__NRF5X_PIN(30, 0, 30),
|
||||||
__NRF5X_PIN(31, 0, 31),
|
__NRF5X_PIN(31, 0, 31),
|
||||||
#ifdef SOC_NRF52840
|
#ifdef SOC_NRF52840
|
||||||
__NRF5X_PIN(32, 1, 0 ),
|
__NRF5X_PIN(32, 1, 0 ),
|
||||||
__NRF5X_PIN(33, 1, 1 ),
|
__NRF5X_PIN(33, 1, 1 ),
|
||||||
__NRF5X_PIN(34, 1, 2 ),
|
__NRF5X_PIN(34, 1, 2 ),
|
||||||
|
@ -110,7 +110,7 @@ static void nrf5x_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nrf_gpio_pin_write(pin, value);
|
nrf_gpio_pin_write(pin, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ static void pin_irq_hdr(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int irq_quantity;
|
int irq_quantity;
|
||||||
|
|
||||||
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
|
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
|
||||||
for(i = 0; i < irq_quantity; i++)
|
for(i = 0; i < irq_quantity; i++)
|
||||||
{
|
{
|
||||||
|
@ -202,13 +202,13 @@ static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
|
||||||
nrfx_err_t err_code;
|
nrfx_err_t err_code;
|
||||||
int i;
|
int i;
|
||||||
int irq_quantity;
|
int irq_quantity;
|
||||||
|
|
||||||
index = get_pin(pin);
|
index = get_pin(pin);
|
||||||
if (index == RT_NULL)
|
if (index == RT_NULL)
|
||||||
{
|
{
|
||||||
return RT_ENOSYS;
|
return RT_ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
|
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
|
||||||
for(i = 0; i < irq_quantity; i++)
|
for(i = 0; i < irq_quantity; i++)
|
||||||
{
|
{
|
||||||
|
@ -227,37 +227,37 @@ static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
|
||||||
{
|
{
|
||||||
return RT_ENOMEM;
|
return RT_ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
level = rt_hw_interrupt_disable();
|
level = rt_hw_interrupt_disable();
|
||||||
pin_irq_hdr_tab[irqindex].pin = pin;
|
pin_irq_hdr_tab[irqindex].pin = pin;
|
||||||
pin_irq_hdr_tab[irqindex].hdr = hdr;
|
pin_irq_hdr_tab[irqindex].hdr = hdr;
|
||||||
pin_irq_hdr_tab[irqindex].mode = mode;
|
pin_irq_hdr_tab[irqindex].mode = mode;
|
||||||
pin_irq_hdr_tab[irqindex].args = args;
|
pin_irq_hdr_tab[irqindex].args = args;
|
||||||
|
|
||||||
if(mode == PIN_IRQ_MODE_RISING)
|
if(mode == PIN_IRQ_MODE_RISING)
|
||||||
{
|
{
|
||||||
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(args);
|
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(args);
|
||||||
inConfig.pull = NRF_GPIO_PIN_PULLDOWN;
|
inConfig.pull = NRF_GPIO_PIN_PULLDOWN;
|
||||||
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(mode == PIN_IRQ_MODE_FALLING)
|
else if(mode == PIN_IRQ_MODE_FALLING)
|
||||||
{
|
{
|
||||||
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(args);
|
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(args);
|
||||||
inConfig.pull = NRF_GPIO_PIN_PULLUP;
|
inConfig.pull = NRF_GPIO_PIN_PULLUP;
|
||||||
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(mode == PIN_IRQ_MODE_RISING_FALLING)
|
else if(mode == PIN_IRQ_MODE_RISING_FALLING)
|
||||||
{
|
{
|
||||||
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(args);
|
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(args);
|
||||||
inConfig.pull = NRF_GPIO_PIN_PULLUP;
|
inConfig.pull = NRF_GPIO_PIN_PULLUP;
|
||||||
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_hw_interrupt_enable(level);
|
rt_hw_interrupt_enable(level);
|
||||||
|
|
||||||
switch(err_code)
|
switch(err_code)
|
||||||
{
|
{
|
||||||
case NRFX_ERROR_BUSY:
|
case NRFX_ERROR_BUSY:
|
||||||
return RT_EBUSY;
|
return RT_EBUSY;
|
||||||
|
@ -282,7 +282,7 @@ static rt_err_t nrf5x_pin_dettach_irq(struct rt_device *device, rt_int32_t pin)
|
||||||
{
|
{
|
||||||
return RT_ENOSYS;
|
return RT_ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
|
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
|
||||||
for(i = 0; i < irq_quantity; i++)
|
for(i = 0; i < irq_quantity; i++)
|
||||||
{
|
{
|
||||||
|
@ -308,7 +308,7 @@ static rt_err_t nrf5x_pin_dettach_irq(struct rt_device *device, rt_int32_t pin)
|
||||||
static rt_err_t nrf5x_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
static rt_err_t nrf5x_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||||
rt_uint32_t enabled)
|
rt_uint32_t enabled)
|
||||||
{
|
{
|
||||||
const struct pin_index *index;
|
const struct pin_index *index;
|
||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
int i;
|
int i;
|
||||||
int irq_quantity;
|
int irq_quantity;
|
||||||
|
@ -337,7 +337,7 @@ static rt_err_t nrf5x_pin_irq_enable(struct rt_device *device, rt_base_t pin,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i >= irq_quantity)
|
if(i >= irq_quantity)
|
||||||
{
|
{
|
||||||
return RT_ENOSYS;
|
return RT_ENOSYS;
|
||||||
|
@ -362,8 +362,8 @@ int rt_hw_pin_init(void)
|
||||||
|
|
||||||
err_code = (nrfx_err_t)rt_device_pin_register("pin", &_nrf5x_pin_ops, RT_NULL);
|
err_code = (nrfx_err_t)rt_device_pin_register("pin", &_nrf5x_pin_ops, RT_NULL);
|
||||||
err_code = nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY);
|
err_code = nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY);
|
||||||
|
|
||||||
switch(err_code)
|
switch(err_code)
|
||||||
{
|
{
|
||||||
case NRFX_ERROR_INVALID_STATE:
|
case NRFX_ERROR_INVALID_STATE:
|
||||||
return RT_EINVAL;
|
return RT_EINVAL;
|
||||||
|
@ -372,7 +372,7 @@ int rt_hw_pin_init(void)
|
||||||
default:
|
default:
|
||||||
return RT_ERROR;;
|
return RT_ERROR;;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
INIT_BOARD_EXPORT(rt_hw_pin_init);
|
INIT_BOARD_EXPORT(rt_hw_pin_init);
|
||||||
|
|
||||||
|
@ -389,90 +389,90 @@ INIT_BOARD_EXPORT(rt_hw_pin_init);
|
||||||
|
|
||||||
void button_1_callback(void *args)
|
void button_1_callback(void *args)
|
||||||
{
|
{
|
||||||
static int flag1 = 0;
|
static int flag1 = 0;
|
||||||
if(flag1 == 0)
|
if(flag1 == 0)
|
||||||
{
|
{
|
||||||
flag1 = 1;
|
flag1 = 1;
|
||||||
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flag1 = 0;
|
flag1 = 0;
|
||||||
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void button_2_callback(void *args)
|
void button_2_callback(void *args)
|
||||||
{
|
{
|
||||||
static int flag2 = 0;
|
static int flag2 = 0;
|
||||||
if(flag2 == 0)
|
if(flag2 == 0)
|
||||||
{
|
{
|
||||||
flag2 = 1;
|
flag2 = 1;
|
||||||
rt_pin_write(DK_BOARD_LED_2, PIN_LOW);
|
rt_pin_write(DK_BOARD_LED_2, PIN_LOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flag2 = 0;
|
flag2 = 0;
|
||||||
rt_pin_write(DK_BOARD_LED_2, PIN_HIGH);
|
rt_pin_write(DK_BOARD_LED_2, PIN_HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void button_3_callback(void *args)
|
void button_3_callback(void *args)
|
||||||
{
|
{
|
||||||
static int flag3 = 0;
|
static int flag3 = 0;
|
||||||
if(flag3 == 0)
|
if(flag3 == 0)
|
||||||
{
|
{
|
||||||
flag3 = 1;
|
flag3 = 1;
|
||||||
rt_pin_write(DK_BOARD_LED_3, PIN_LOW);
|
rt_pin_write(DK_BOARD_LED_3, PIN_LOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flag3 = 0;
|
flag3 = 0;
|
||||||
rt_pin_write(DK_BOARD_LED_3, PIN_HIGH);
|
rt_pin_write(DK_BOARD_LED_3, PIN_HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void button_4_callback(void *args)
|
void button_4_callback(void *args)
|
||||||
{
|
{
|
||||||
static int flag4 = 0;
|
static int flag4 = 0;
|
||||||
if(flag4 == 0)
|
if(flag4 == 0)
|
||||||
{
|
{
|
||||||
flag4 = 1;
|
flag4 = 1;
|
||||||
rt_pin_write(DK_BOARD_LED_4, PIN_LOW);
|
rt_pin_write(DK_BOARD_LED_4, PIN_LOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flag4 = 0;
|
flag4 = 0;
|
||||||
rt_pin_write(DK_BOARD_LED_4, PIN_HIGH);
|
rt_pin_write(DK_BOARD_LED_4, PIN_HIGH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpio_sample(void)
|
void gpio_sample(void)
|
||||||
{
|
{
|
||||||
rt_err_t err_code;
|
rt_err_t err_code;
|
||||||
|
|
||||||
rt_pin_mode(DK_BOARD_LED_1, PIN_MODE_OUTPUT);
|
|
||||||
rt_pin_mode(DK_BOARD_LED_2, PIN_MODE_OUTPUT);
|
|
||||||
rt_pin_mode(DK_BOARD_LED_3, PIN_MODE_OUTPUT);
|
|
||||||
rt_pin_mode(DK_BOARD_LED_4, PIN_MODE_OUTPUT);
|
|
||||||
|
|
||||||
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
rt_pin_mode(DK_BOARD_LED_1, PIN_MODE_OUTPUT);
|
||||||
rt_pin_write(DK_BOARD_LED_2, PIN_HIGH);
|
rt_pin_mode(DK_BOARD_LED_2, PIN_MODE_OUTPUT);
|
||||||
rt_pin_write(DK_BOARD_LED_3, PIN_HIGH);
|
rt_pin_mode(DK_BOARD_LED_3, PIN_MODE_OUTPUT);
|
||||||
rt_pin_write(DK_BOARD_LED_4, PIN_HIGH);
|
rt_pin_mode(DK_BOARD_LED_4, PIN_MODE_OUTPUT);
|
||||||
|
|
||||||
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_1, PIN_IRQ_MODE_FALLING,
|
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
||||||
|
rt_pin_write(DK_BOARD_LED_2, PIN_HIGH);
|
||||||
|
rt_pin_write(DK_BOARD_LED_3, PIN_HIGH);
|
||||||
|
rt_pin_write(DK_BOARD_LED_4, PIN_HIGH);
|
||||||
|
|
||||||
|
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_1, PIN_IRQ_MODE_FALLING,
|
||||||
button_1_callback, (void*) true); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
button_1_callback, (void*) true); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
||||||
rt_pin_irq_enable(DK_BOARD_BUTTON_1, PIN_IRQ_ENABLE);
|
rt_pin_irq_enable(DK_BOARD_BUTTON_1, PIN_IRQ_ENABLE);
|
||||||
|
|
||||||
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_2, PIN_IRQ_MODE_FALLING,
|
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_2, PIN_IRQ_MODE_FALLING,
|
||||||
button_2_callback, (void*) true); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
button_2_callback, (void*) true); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
||||||
rt_pin_irq_enable(DK_BOARD_BUTTON_2, PIN_IRQ_ENABLE);
|
rt_pin_irq_enable(DK_BOARD_BUTTON_2, PIN_IRQ_ENABLE);
|
||||||
|
|
||||||
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_3, PIN_IRQ_MODE_FALLING,
|
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_3, PIN_IRQ_MODE_FALLING,
|
||||||
button_3_callback, (void*) true); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
button_3_callback, (void*) true); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
||||||
rt_pin_irq_enable(DK_BOARD_BUTTON_3, PIN_IRQ_ENABLE);
|
rt_pin_irq_enable(DK_BOARD_BUTTON_3, PIN_IRQ_ENABLE);
|
||||||
|
|
||||||
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_4, PIN_IRQ_MODE_FALLING,
|
err_code = rt_pin_attach_irq(DK_BOARD_BUTTON_4, PIN_IRQ_MODE_FALLING,
|
||||||
button_4_callback, (void*) false); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
button_4_callback, (void*) false); //true: hi_accuracy(IN_EVENT),false: lo_accuracy(PORT_EVENT)
|
||||||
rt_pin_irq_enable(DK_BOARD_BUTTON_4, PIN_IRQ_ENABLE);
|
rt_pin_irq_enable(DK_BOARD_BUTTON_4, PIN_IRQ_ENABLE);
|
||||||
}
|
}
|
||||||
MSH_CMD_EXPORT(gpio_sample, gpio sample);
|
MSH_CMD_EXPORT(gpio_sample, gpio sample);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
* 2020-11-15 xckhmf First Verison
|
* 2020-11-15 xckhmf First Verison
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtdevice.h>
|
#include <rtdevice.h>
|
||||||
#include <nrfx_twi_twim.h>
|
#include <nrfx_twi_twim.h>
|
||||||
#include <nrfx_twim.h>
|
#include <nrfx_twim.h>
|
||||||
|
@ -23,7 +23,7 @@ typedef struct
|
||||||
}drv_i2c_cfg_t;
|
}drv_i2c_cfg_t;
|
||||||
|
|
||||||
#ifdef BSP_USING_I2C0
|
#ifdef BSP_USING_I2C0
|
||||||
static drv_i2c_cfg_t drv_i2c_0 =
|
static drv_i2c_cfg_t drv_i2c_0 =
|
||||||
{
|
{
|
||||||
.freq = NRF_TWIM_FREQ_400K,
|
.freq = NRF_TWIM_FREQ_400K,
|
||||||
.scl_pin = BSP_I2C0_SCL_PIN,
|
.scl_pin = BSP_I2C0_SCL_PIN,
|
||||||
|
@ -33,7 +33,7 @@ static drv_i2c_cfg_t drv_i2c_0 =
|
||||||
static struct rt_i2c_bus_device i2c0_bus;
|
static struct rt_i2c_bus_device i2c0_bus;
|
||||||
#endif
|
#endif
|
||||||
#ifdef BSP_USING_I2C1
|
#ifdef BSP_USING_I2C1
|
||||||
static drv_i2c_cfg_t drv_i2c_1 =
|
static drv_i2c_cfg_t drv_i2c_1 =
|
||||||
{
|
{
|
||||||
.freq = NRF_TWIM_FREQ_400K,
|
.freq = NRF_TWIM_FREQ_400K,
|
||||||
.scl_pin = BSP_I2C1_SCL_PIN,
|
.scl_pin = BSP_I2C1_SCL_PIN,
|
||||||
|
@ -42,17 +42,17 @@ static drv_i2c_cfg_t drv_i2c_1 =
|
||||||
};
|
};
|
||||||
static struct rt_i2c_bus_device i2c1_bus;
|
static struct rt_i2c_bus_device i2c1_bus;
|
||||||
#endif
|
#endif
|
||||||
static int twi_master_init(struct rt_i2c_bus_device *bus)
|
static int twi_master_init(struct rt_i2c_bus_device *bus)
|
||||||
{
|
{
|
||||||
nrfx_err_t rtn;
|
nrfx_err_t rtn;
|
||||||
nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG(0,0);
|
nrfx_twim_config_t config = NRFX_TWIM_DEFAULT_CONFIG(0,0);
|
||||||
drv_i2c_cfg_t *p_cfg = bus->priv;
|
drv_i2c_cfg_t *p_cfg = bus->priv;
|
||||||
nrfx_twim_t const * p_instance = &p_cfg->twi_instance;
|
nrfx_twim_t const * p_instance = &p_cfg->twi_instance;
|
||||||
|
|
||||||
config.frequency = p_cfg->freq;
|
config.frequency = p_cfg->freq;
|
||||||
config.scl = p_cfg->scl_pin;
|
config.scl = p_cfg->scl_pin;
|
||||||
config.sda = p_cfg->sda_pin;
|
config.sda = p_cfg->sda_pin;
|
||||||
|
|
||||||
nrfx_twi_twim_bus_recover(config.scl,config.sda);
|
nrfx_twi_twim_bus_recover(config.scl,config.sda);
|
||||||
|
|
||||||
rtn = nrfx_twim_init(p_instance,&config,NULL,NULL);
|
rtn = nrfx_twim_init(p_instance,&config,NULL,NULL);
|
||||||
|
@ -67,8 +67,8 @@ static rt_size_t _master_xfer(struct rt_i2c_bus_device *bus,
|
||||||
nrfx_twim_t const * p_instance = &((drv_i2c_cfg_t *)bus->priv)->twi_instance;
|
nrfx_twim_t const * p_instance = &((drv_i2c_cfg_t *)bus->priv)->twi_instance;
|
||||||
nrfx_err_t ret = NRFX_ERROR_INTERNAL;
|
nrfx_err_t ret = NRFX_ERROR_INTERNAL;
|
||||||
uint32_t no_stop_flag = 0;
|
uint32_t no_stop_flag = 0;
|
||||||
|
|
||||||
nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(msgs->addr,msgs->buf, msgs->len);
|
nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(msgs->addr,msgs->buf, msgs->len);
|
||||||
if((msgs->flags & 0x01) == RT_I2C_WR)
|
if((msgs->flags & 0x01) == RT_I2C_WR)
|
||||||
{
|
{
|
||||||
xfer.type = NRFX_TWIM_XFER_TX;
|
xfer.type = NRFX_TWIM_XFER_TX;
|
||||||
|
@ -83,7 +83,7 @@ static rt_size_t _master_xfer(struct rt_i2c_bus_device *bus,
|
||||||
}
|
}
|
||||||
ret = nrfx_twim_xfer(p_instance,&xfer,no_stop_flag);
|
ret = nrfx_twim_xfer(p_instance,&xfer,no_stop_flag);
|
||||||
return (ret == NRFX_SUCCESS) ? msgs->len : 0;
|
return (ret == NRFX_SUCCESS) ? msgs->len : 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct rt_i2c_bus_device_ops _i2c_ops =
|
static const struct rt_i2c_bus_device_ops _i2c_ops =
|
||||||
|
@ -94,23 +94,23 @@ static const struct rt_i2c_bus_device_ops _i2c_ops =
|
||||||
};
|
};
|
||||||
|
|
||||||
int rt_hw_i2c_init(void)
|
int rt_hw_i2c_init(void)
|
||||||
{
|
{
|
||||||
#ifdef BSP_USING_I2C0
|
#ifdef BSP_USING_I2C0
|
||||||
i2c0_bus.ops= &_i2c_ops;
|
i2c0_bus.ops= &_i2c_ops;
|
||||||
i2c0_bus.timeout = 0;
|
i2c0_bus.timeout = 0;
|
||||||
i2c0_bus.priv = (void *)&drv_i2c_0;
|
i2c0_bus.priv = (void *)&drv_i2c_0;
|
||||||
twi_master_init(&i2c0_bus);
|
twi_master_init(&i2c0_bus);
|
||||||
rt_i2c_bus_device_register(&i2c0_bus, "i2c0");
|
rt_i2c_bus_device_register(&i2c0_bus, "i2c0");
|
||||||
#endif
|
#endif
|
||||||
#ifdef BSP_USING_I2C1
|
#ifdef BSP_USING_I2C1
|
||||||
i2c1_bus.ops= &_i2c_ops;
|
i2c1_bus.ops= &_i2c_ops;
|
||||||
i2c1_bus.timeout = 0;
|
i2c1_bus.timeout = 0;
|
||||||
i2c1_bus.priv = (void *)&drv_i2c_1;
|
i2c1_bus.priv = (void *)&drv_i2c_1;
|
||||||
twi_master_init(&i2c1_bus);
|
twi_master_init(&i2c1_bus);
|
||||||
rt_i2c_bus_device_register(&i2c1_bus, "i2c1");
|
rt_i2c_bus_device_register(&i2c1_bus, "i2c1");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_BOARD_EXPORT(rt_hw_i2c_init);
|
INIT_BOARD_EXPORT(rt_hw_i2c_init);
|
||||||
#endif /* defined(BSP_USING_I2C0) || defined(BSP_USING_I2C1) */
|
#endif /* defined(BSP_USING_I2C0) || defined(BSP_USING_I2C1) */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
struct mcu_pwm
|
struct mcu_pwm
|
||||||
{
|
{
|
||||||
struct rt_device_pwm pwm_device;
|
struct rt_device_pwm pwm_device;
|
||||||
|
|
||||||
nrfx_pwm_t *pwm_handle;
|
nrfx_pwm_t *pwm_handle;
|
||||||
nrf_pwm_values_individual_t m_demo1_seq_values;
|
nrf_pwm_values_individual_t m_demo1_seq_values;
|
||||||
nrf_pwm_sequence_t m_demo1_seq;
|
nrf_pwm_sequence_t m_demo1_seq;
|
||||||
|
@ -429,4 +429,4 @@ static int pwm_led_sample(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
MSH_CMD_EXPORT(pwm_led_sample, pwm sample);
|
MSH_CMD_EXPORT(pwm_led_sample, pwm sample);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -42,7 +42,7 @@ static uint32_t tick = 0;
|
||||||
static void rtc_callback(nrfx_rtc_int_type_t int_type)
|
static void rtc_callback(nrfx_rtc_int_type_t int_type)
|
||||||
{
|
{
|
||||||
static uint32_t count = 0;
|
static uint32_t count = 0;
|
||||||
|
|
||||||
if (int_type == NRFX_RTC_INT_TICK)
|
if (int_type == NRFX_RTC_INT_TICK)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -40,7 +40,7 @@ static struct nrfx_drv_spi_config spi_config[] =
|
||||||
static struct nrfx_drv_spi spi_bus_obj[sizeof(spi_config) / sizeof(spi_config[0])];
|
static struct nrfx_drv_spi spi_bus_obj[sizeof(spi_config) / sizeof(spi_config[0])];
|
||||||
|
|
||||||
//Configure SPI bus pins using the menuconfig
|
//Configure SPI bus pins using the menuconfig
|
||||||
static struct nrfx_drv_spi_pin_config bsp_spi_pin[] =
|
static struct nrfx_drv_spi_pin_config bsp_spi_pin[] =
|
||||||
{
|
{
|
||||||
#ifdef BSP_USING_SPI0
|
#ifdef BSP_USING_SPI0
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ nrfx_spi_evt_handler_t spi_handler[] = {spi0_handler, spi1_handler, spi2_handler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function config spi bus
|
* @brief This function config spi bus
|
||||||
* @param device
|
* @param device
|
||||||
* @param configuration
|
* @param configuration
|
||||||
* @retval RT_EOK / RT_ERROR
|
* @retval RT_EOK / RT_ERROR
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +118,7 @@ static rt_err_t spi_configure(struct rt_spi_device *device,
|
||||||
RT_ASSERT(index != 0xFF);
|
RT_ASSERT(index != 0xFF);
|
||||||
|
|
||||||
nrfx_spi_t spi = spi_bus_obj[index].spi;
|
nrfx_spi_t spi = spi_bus_obj[index].spi;
|
||||||
nrfx_spi_config_t config = NRFX_SPI_DEFAULT_CONFIG(bsp_spi_pin[index].sck_pin,
|
nrfx_spi_config_t config = NRFX_SPI_DEFAULT_CONFIG(bsp_spi_pin[index].sck_pin,
|
||||||
bsp_spi_pin[index].mosi_pin, bsp_spi_pin[index].miso_pin, NRFX_SPI_PIN_NOT_USED);
|
bsp_spi_pin[index].mosi_pin, bsp_spi_pin[index].miso_pin, NRFX_SPI_PIN_NOT_USED);
|
||||||
|
|
||||||
/* spi config ss pin */
|
/* spi config ss pin */
|
||||||
|
@ -211,7 +211,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||||
nrf_gpio_pin_clear((uint32_t)device->parent.user_data);
|
nrf_gpio_pin_clear((uint32_t)device->parent.user_data);
|
||||||
}
|
}
|
||||||
p_xfer_desc.p_rx_buffer = message->recv_buf;
|
p_xfer_desc.p_rx_buffer = message->recv_buf;
|
||||||
p_xfer_desc.rx_length = message->length;
|
p_xfer_desc.rx_length = message->length;
|
||||||
p_xfer_desc.p_tx_buffer = message->send_buf;
|
p_xfer_desc.p_tx_buffer = message->send_buf;
|
||||||
p_xfer_desc.tx_length = message->length ;
|
p_xfer_desc.tx_length = message->length ;
|
||||||
if(message->send_buf == RT_NULL)
|
if(message->send_buf == RT_NULL)
|
||||||
|
@ -220,7 +220,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||||
}
|
}
|
||||||
if(message->recv_buf == RT_NULL)
|
if(message->recv_buf == RT_NULL)
|
||||||
{
|
{
|
||||||
p_xfer_desc.rx_length = 0;
|
p_xfer_desc.rx_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nrf_ret = nrfx_spi_xfer(p_instance, &p_xfer_desc, 0);
|
nrf_ret = nrfx_spi_xfer(p_instance, &p_xfer_desc, 0);
|
||||||
|
@ -228,14 +228,14 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
|
||||||
{
|
{
|
||||||
nrf_gpio_pin_set((uint32_t)device->parent.user_data);
|
nrf_gpio_pin_set((uint32_t)device->parent.user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NRFX_SUCCESS != nrf_ret)
|
if( NRFX_SUCCESS != nrf_ret)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return message->length;
|
return message->length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -57,7 +57,7 @@ struct nrfx_drv_spi_config
|
||||||
nrfx_spi_t spi;
|
nrfx_spi_t spi;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nrfx_drv_spi
|
struct nrfx_drv_spi
|
||||||
{
|
{
|
||||||
nrfx_spi_t spi; /* nrfx spi driver instance. */
|
nrfx_spi_t spi; /* nrfx spi driver instance. */
|
||||||
nrfx_spi_config_t spi_config; /* nrfx spi config Configuration */
|
nrfx_spi_config_t spi_config; /* nrfx spi config Configuration */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -44,16 +44,16 @@ drv_uart_cfg_t m_uart0_cfg = {
|
||||||
|
|
||||||
#ifdef BSP_USING_UART0
|
#ifdef BSP_USING_UART0
|
||||||
static void uart0_event_hander(nrfx_uart_event_t const *p_event,void *p_context)
|
static void uart0_event_hander(nrfx_uart_event_t const *p_event,void *p_context)
|
||||||
{
|
{
|
||||||
if (p_event->type == NRFX_UART_EVT_RX_DONE)
|
if (p_event->type == NRFX_UART_EVT_RX_DONE)
|
||||||
{
|
{
|
||||||
if(p_event->data.rxtx.bytes == 1)
|
if(p_event->data.rxtx.bytes == 1)
|
||||||
{
|
{
|
||||||
m_uart0_cfg.rx_length = p_event->data.rxtx.bytes;
|
m_uart0_cfg.rx_length = p_event->data.rxtx.bytes;
|
||||||
|
|
||||||
/* rx_byte equal p_data */
|
/* rx_byte equal p_data */
|
||||||
//m_uart0_cfg.rx_byte = *(p_event->data.rxtx.p_data);
|
//m_uart0_cfg.rx_byte = *(p_event->data.rxtx.p_data);
|
||||||
|
|
||||||
rt_hw_serial_isr(m_uart0_cfg.serial, RT_SERIAL_EVENT_RX_IND);
|
rt_hw_serial_isr(m_uart0_cfg.serial, RT_SERIAL_EVENT_RX_IND);
|
||||||
}
|
}
|
||||||
nrfx_uart_rx(&(m_uart0_cfg.uart),&m_uart0_cfg.rx_byte,1);
|
nrfx_uart_rx(&(m_uart0_cfg.uart),&m_uart0_cfg.rx_byte,1);
|
||||||
|
@ -72,7 +72,7 @@ static rt_err_t _uart_cfg(struct rt_serial_device *serial, struct serial_configu
|
||||||
|
|
||||||
RT_ASSERT(serial != RT_NULL);
|
RT_ASSERT(serial != RT_NULL);
|
||||||
RT_ASSERT(cfg != RT_NULL);
|
RT_ASSERT(cfg != RT_NULL);
|
||||||
|
|
||||||
if (serial->parent.user_data == RT_NULL)
|
if (serial->parent.user_data == RT_NULL)
|
||||||
{
|
{
|
||||||
return -RT_ERROR;
|
return -RT_ERROR;
|
||||||
|
@ -107,7 +107,7 @@ static rt_err_t _uart_cfg(struct rt_serial_device *serial, struct serial_configu
|
||||||
config.hal_cfg.hwfc = NRF_UART_HWFC_DISABLED;
|
config.hal_cfg.hwfc = NRF_UART_HWFC_DISABLED;
|
||||||
config.pselrxd = instance->rx_pin;
|
config.pselrxd = instance->rx_pin;
|
||||||
config.pseltxd = instance->tx_pin;
|
config.pseltxd = instance->tx_pin;
|
||||||
|
|
||||||
nrfx_uart_init(&(instance->uart), &config, instance->event_handler);
|
nrfx_uart_init(&(instance->uart), &config, instance->event_handler);
|
||||||
nrfx_uart_rx(&(instance->uart),&(instance->rx_byte),1);
|
nrfx_uart_rx(&(instance->uart),&(instance->rx_byte),1);
|
||||||
nrf_uart_int_disable(instance->uart.p_reg, NRF_UART_INT_MASK_TXDRDY);
|
nrf_uart_int_disable(instance->uart.p_reg, NRF_UART_INT_MASK_TXDRDY);
|
||||||
|
@ -187,7 +187,7 @@ static int _uart_putc(struct rt_serial_device *serial, char c)
|
||||||
while (!nrf_uart_event_check(instance->uart.p_reg, NRF_UART_EVENT_TXDRDY))
|
while (!nrf_uart_event_check(instance->uart.p_reg, NRF_UART_EVENT_TXDRDY))
|
||||||
{
|
{
|
||||||
//wait for TXD send
|
//wait for TXD send
|
||||||
}
|
}
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ static int _uart_getc(struct rt_serial_device *serial)
|
||||||
if (serial->parent.user_data != RT_NULL)
|
if (serial->parent.user_data != RT_NULL)
|
||||||
{
|
{
|
||||||
instance = (drv_uart_cfg_t*)serial->parent.user_data;
|
instance = (drv_uart_cfg_t*)serial->parent.user_data;
|
||||||
}
|
}
|
||||||
if(instance->rx_length)
|
if(instance->rx_length)
|
||||||
{
|
{
|
||||||
ch = instance->rx_byte;
|
ch = instance->rx_byte;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -68,7 +68,7 @@ static void uarte_evt_handler(nrfx_uarte_event_t const * p_event,
|
||||||
case NRFX_UARTE_EVT_ERROR:
|
case NRFX_UARTE_EVT_ERROR:
|
||||||
(void)nrfx_uarte_rx(&(p_cb->uarte_instance), p_cb->rx_buffer, 1);
|
(void)nrfx_uarte_rx(&(p_cb->uarte_instance), p_cb->rx_buffer, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NRFX_UARTE_EVT_TX_DONE:
|
case NRFX_UARTE_EVT_TX_DONE:
|
||||||
if(p_cb->serial->parent.open_flag&RT_DEVICE_FLAG_INT_TX)
|
if(p_cb->serial->parent.open_flag&RT_DEVICE_FLAG_INT_TX)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ static rt_err_t _uart_cfg(struct rt_serial_device *serial, struct serial_configu
|
||||||
|
|
||||||
RT_ASSERT(serial != RT_NULL);
|
RT_ASSERT(serial != RT_NULL);
|
||||||
RT_ASSERT(cfg != RT_NULL);
|
RT_ASSERT(cfg != RT_NULL);
|
||||||
|
|
||||||
if (serial->parent.user_data == RT_NULL)
|
if (serial->parent.user_data == RT_NULL)
|
||||||
{
|
{
|
||||||
return -RT_ERROR;
|
return -RT_ERROR;
|
||||||
|
@ -145,11 +145,11 @@ static rt_err_t _uart_cfg(struct rt_serial_device *serial, struct serial_configu
|
||||||
NRF_UARTE_PARITY_EXCLUDED:NRF_UARTE_PARITY_INCLUDED;
|
NRF_UARTE_PARITY_EXCLUDED:NRF_UARTE_PARITY_INCLUDED;
|
||||||
config.hal_cfg.hwfc = NRF_UARTE_HWFC_DISABLED;
|
config.hal_cfg.hwfc = NRF_UARTE_HWFC_DISABLED;
|
||||||
config.pselrxd = p_cb->rx_pin;
|
config.pselrxd = p_cb->rx_pin;
|
||||||
config.pseltxd = p_cb->tx_pin;
|
config.pseltxd = p_cb->tx_pin;
|
||||||
config.p_context = (void *)p_cb;
|
config.p_context = (void *)p_cb;
|
||||||
|
|
||||||
nrfx_uarte_init(&(p_cb->uarte_instance),(nrfx_uarte_config_t const *)&config,uarte_evt_handler);
|
nrfx_uarte_init(&(p_cb->uarte_instance),(nrfx_uarte_config_t const *)&config,uarte_evt_handler);
|
||||||
nrfx_uarte_rx(&(p_cb->uarte_instance),p_cb->rx_buffer,1);
|
nrfx_uarte_rx(&(p_cb->uarte_instance),p_cb->rx_buffer,1);
|
||||||
p_cb->isInit = true;
|
p_cb->isInit = true;
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ static int _uart_putc(struct rt_serial_device *serial, char c)
|
||||||
while(nrfx_uarte_tx_in_progress(&(p_cb->uarte_instance)))
|
while(nrfx_uarte_tx_in_progress(&(p_cb->uarte_instance)))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ static int _uart_getc(struct rt_serial_device *serial)
|
||||||
if (serial->parent.user_data != RT_NULL)
|
if (serial->parent.user_data != RT_NULL)
|
||||||
{
|
{
|
||||||
p_cb = (drv_uart_cb_t*)serial->parent.user_data;
|
p_cb = (drv_uart_cb_t*)serial->parent.user_data;
|
||||||
}
|
}
|
||||||
if(p_cb->rx_length)
|
if(p_cb->rx_length)
|
||||||
{
|
{
|
||||||
ch = p_cb->rx_buffer[0];
|
ch = p_cb->rx_buffer[0];
|
||||||
|
@ -260,15 +260,15 @@ void rt_hw_uart_init(void)
|
||||||
{
|
{
|
||||||
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
||||||
|
|
||||||
#ifdef BSP_USING_UART0
|
#ifdef BSP_USING_UART0
|
||||||
m_serial_0.config = config;
|
m_serial_0.config = config;
|
||||||
m_serial_0.ops = &_uart_ops;
|
m_serial_0.ops = &_uart_ops;
|
||||||
m_uarte0_cb.serial = &m_serial_0;
|
m_uarte0_cb.serial = &m_serial_0;
|
||||||
rt_hw_serial_register(&m_serial_0, "uart0", \
|
rt_hw_serial_register(&m_serial_0, "uart0", \
|
||||||
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX , &m_uarte0_cb);
|
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX , &m_uarte0_cb);
|
||||||
#endif /* BSP_USING_UART0 */
|
#endif /* BSP_USING_UART0 */
|
||||||
|
|
||||||
#ifdef BSP_USING_UART1
|
#ifdef BSP_USING_UART1
|
||||||
m_serial_1.config = config;
|
m_serial_1.config = config;
|
||||||
m_serial_1.ops = &_uart_ops;
|
m_serial_1.ops = &_uart_ops;
|
||||||
m_uarte1_cb.serial = &m_serial_1;
|
m_uarte1_cb.serial = &m_serial_1;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -603,12 +603,12 @@ static void _stack_thread(void *parameter)
|
||||||
|
|
||||||
result = rt_event_recv(stack_event, STACK_EV_DISCON | STACK_EV_DISPATCH | STACK_EV_KEY,
|
result = rt_event_recv(stack_event, STACK_EV_DISCON | STACK_EV_DISPATCH | STACK_EV_KEY,
|
||||||
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, next_timeout, &event);
|
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, next_timeout, &event);
|
||||||
if (result == -RT_ETIMEOUT)
|
if (result == -RT_ETIMEOUT)
|
||||||
{
|
{
|
||||||
LOG_E("wait completed timeout");
|
LOG_E("wait completed timeout");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (result == -RT_ERROR)
|
else if (result == -RT_ERROR)
|
||||||
{
|
{
|
||||||
LOG_E("event received error");
|
LOG_E("event received error");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -64,7 +64,7 @@ void OSTick_Handler( void )
|
||||||
{
|
{
|
||||||
uint32_t diff;
|
uint32_t diff;
|
||||||
|
|
||||||
/* enter interrupt */
|
/* enter interrupt */
|
||||||
rt_interrupt_enter();
|
rt_interrupt_enter();
|
||||||
diff = _tick_distance();
|
diff = _tick_distance();
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ static void _wakeup_tick_adjust(void)
|
||||||
|
|
||||||
if (rt_thread_self() != RT_NULL)
|
if (rt_thread_self() != RT_NULL)
|
||||||
{
|
{
|
||||||
struct rt_thread *thread;
|
struct rt_thread *thread;
|
||||||
|
|
||||||
/* check time slice */
|
/* check time slice */
|
||||||
thread = rt_thread_self();
|
thread = rt_thread_self();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -16,16 +16,16 @@
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int count = 1;
|
int count = 1;
|
||||||
rt_pin_mode(DK_BOARD_LED_1, PIN_MODE_OUTPUT);
|
rt_pin_mode(DK_BOARD_LED_1, PIN_MODE_OUTPUT);
|
||||||
|
|
||||||
while (count++)
|
while (count++)
|
||||||
{
|
{
|
||||||
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
||||||
rt_thread_mdelay(500);
|
rt_thread_mdelay(500);
|
||||||
|
|
||||||
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
||||||
rt_thread_mdelay(500);
|
rt_thread_mdelay(500);
|
||||||
}
|
}
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef APP_CONFIG_H
|
#ifndef APP_CONFIG_H
|
||||||
#define APP_CONFIG_H
|
#define APP_CONFIG_H
|
||||||
|
|
||||||
#endif //APP_CONFIG_H
|
#endif //APP_CONFIG_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
@ -16,16 +16,16 @@
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int count = 1;
|
int count = 1;
|
||||||
rt_pin_mode(DK_BOARD_LED_1, PIN_MODE_OUTPUT);
|
rt_pin_mode(DK_BOARD_LED_1, PIN_MODE_OUTPUT);
|
||||||
|
|
||||||
while (count++)
|
while (count++)
|
||||||
{
|
{
|
||||||
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
|
||||||
rt_thread_mdelay(500);
|
rt_thread_mdelay(500);
|
||||||
|
|
||||||
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
||||||
rt_thread_mdelay(500);
|
rt_thread_mdelay(500);
|
||||||
}
|
}
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef APP_CONFIG_H
|
#ifndef APP_CONFIG_H
|
||||||
#define APP_CONFIG_H
|
#define APP_CONFIG_H
|
||||||
|
|
||||||
#endif //APP_CONFIG_H
|
#endif //APP_CONFIG_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue