7847c5e98d
* Microchip SAM MCU BSP update and add ethernet driver 1. Update Microchip SAM MCU BSP, add I2C, GMAC, ADC driver support. 2. Add ethernet driver support of SAM MCU for RT-Thread. * Add GMAC and I2C driver support 1. Update MCU BSP to support I2C/ADC/GMAC peripherals. 2. Add I2C and ethernet driver and LWIP support. 3. Update serial driver. * Add I2C driver and move some files to the common folder 1. Add I2C driver. 2. Move the same drivers and demo code to same folder to reduce duplicated code.
86 lines
1.6 KiB
C
86 lines
1.6 KiB
C
/*
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Email Notes
|
|
* 2022-04-16 Kevin.Liu kevin.liu.mchp@gmail.com First Release
|
|
*/
|
|
|
|
#include <rtthread.h>
|
|
|
|
#ifdef RT_USING_FINSH
|
|
#include <finsh.h>
|
|
#include <shell.h>
|
|
#endif
|
|
|
|
#include "atmel_start.h"
|
|
#include <hal_gpio.h>
|
|
|
|
#ifdef SAM_CAN_EXAMPLE
|
|
#include "can_demo.h"
|
|
#endif
|
|
|
|
#ifdef SAM_I2C_EXAMPLE
|
|
#include "i2c_demo.h"
|
|
#endif
|
|
|
|
#ifdef SAM_ADC_EXAMPLE
|
|
#include "adc_demo.h"
|
|
#endif
|
|
|
|
static rt_uint8_t led_stack[ 512 ];
|
|
static struct rt_thread led_thread;
|
|
|
|
static void led_thread_entry(void* parameter)
|
|
{
|
|
unsigned int count=0;
|
|
|
|
while (1)
|
|
{
|
|
/* toggle led */
|
|
#ifndef RT_USING_FINSH
|
|
rt_kprintf("led toggle, count : %d\r\n",count);
|
|
#endif
|
|
count++;
|
|
gpio_toggle_pin_level(LED0);
|
|
rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */
|
|
}
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
rt_err_t result;
|
|
|
|
/* initialize led thread */
|
|
result = rt_thread_init(&led_thread,
|
|
"led",
|
|
led_thread_entry,
|
|
RT_NULL,
|
|
(rt_uint8_t*)&led_stack[0],
|
|
sizeof(led_stack),
|
|
RT_THREAD_PRIORITY_MAX/3,
|
|
5);
|
|
if (result == RT_EOK)
|
|
{
|
|
rt_thread_startup(&led_thread);
|
|
}
|
|
|
|
#ifdef SAM_CAN_EXAMPLE
|
|
can_demo_run();
|
|
#endif
|
|
|
|
#ifdef SAM_I2C_EXAMPLE
|
|
i2c_demo_run();
|
|
#endif
|
|
|
|
#ifdef SAM_ADC_EXAMPLE
|
|
adc_demo_run();
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*@}*/
|