mirror of
https://github.com/pvvx/RTL00MP3.git
synced 2025-07-31 12:41:06 +00:00
add example
This commit is contained in:
parent
0cd01e4dc1
commit
5cd34b0c9f
75 changed files with 6023 additions and 217 deletions
|
|
@ -1,33 +1,26 @@
|
|||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "example_uart_update.h"
|
||||
#include <platform/platform_stdlib.h>
|
||||
|
||||
#define XMODEM_UART_IDX 0
|
||||
#define XMODEM_UART_MUX 2
|
||||
#define XMODEM_UART_BAUDRATE 115200
|
||||
|
||||
extern void OTU_FW_Update(u8, u8, u32);
|
||||
|
||||
int is_update_image_enable(gpio_t *gpio_uart_update_eable)
|
||||
{
|
||||
|
||||
HAL_GPIO_PIN GPIO_Pin;
|
||||
GPIO_InitTypeDef GPIO_Pin;
|
||||
u32 active_state;
|
||||
// gpio_t gpio_uart_update_eable;
|
||||
int ret = 0;
|
||||
#if 0
|
||||
GPIO_Pin.pin_name = 0xC4;
|
||||
//low active
|
||||
GPIO_Pin.pin_mode = DIN_PULL_HIGH;
|
||||
active_state = GPIO_PIN_LOW;
|
||||
|
||||
HAL_GPIO_Init(&GPIO_Pin);
|
||||
|
||||
if (HAL_GPIO_ReadPin(&GPIO_Pin) == active_state)
|
||||
ret = 0;
|
||||
else
|
||||
ret = 1;
|
||||
|
||||
HAL_GPIO_DeInit(&GPIO_Pin);
|
||||
#else
|
||||
|
||||
gpio_init(gpio_uart_update_eable, PIN_NAME);
|
||||
gpio_dir(gpio_uart_update_eable, PIN_INPUT); // Direction: Input
|
||||
gpio_mode(gpio_uart_update_eable, PullUp); // Pull-High
|
||||
// ret = gpio_read(&gpio_uart_update_eable);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -40,14 +33,16 @@ void example_uart_update_thread(void *param)
|
|||
//polling MAX_WAIT_TIME*50ms
|
||||
while(count <= MAX_WAIT_TIME)
|
||||
{
|
||||
printf(" waitting update enable\r\n");
|
||||
printf("waitting update enable\r\n");
|
||||
if(gpio_read(&gpio_uart_update_eable) == 0){
|
||||
printf(" update image enabled!\r\n");
|
||||
uart_ymodem();
|
||||
printf("update image enabled with xmodem protocol!\r\n");
|
||||
//uart_ymodem();
|
||||
OTU_FW_Update(XMODEM_UART_IDX, XMODEM_UART_MUX, XMODEM_UART_BAUDRATE);
|
||||
break;
|
||||
}
|
||||
else{
|
||||
RtlMsleepOS(50);
|
||||
//RtlMsleepOS(50);
|
||||
rtw_msleep_os(50);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,78 @@
|
|||
|
||||
#include "PinNames.h"
|
||||
#include "gpio_api.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "osdep_api.h"
|
||||
//#include "hal_gpio.h"
|
||||
//#include "osdep_api.h"
|
||||
#include "osdep_service.h"
|
||||
|
||||
#define PIN_NAME PC_2
|
||||
#define MAX_WAIT_TIME 100
|
||||
#if defined(CONFIG_PLATFORM_8711B)
|
||||
#define PIN_NAME PA_5
|
||||
#else
|
||||
#define PIN_NAME PC_2
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_Mode_IN = 0x00, /*!< GPIO Input Mode */
|
||||
GPIO_Mode_OUT = 0x01, /*!< GPIO Output Mode */
|
||||
GPIO_Mode_INT = 0x02, /*!< GPIO Interrupt Mode */
|
||||
GPIO_Mode_MAX = 0x03,
|
||||
}GPIOMode_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief GPIO Configuration PullUp PullDown enumeration
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_PuPd_NOPULL = 0x00, /*!< GPIO Interrnal HIGHZ */
|
||||
GPIO_PuPd_DOWN = 0x01, /*!< GPIO Interrnal Pull DOWN */
|
||||
GPIO_PuPd_UP = 0x02, /*!< GPIO Interrnal Pull UP */
|
||||
}GPIOPuPd_TypeDef;
|
||||
|
||||
/**
|
||||
* @brief Setting interrupt's trigger type
|
||||
*
|
||||
* Setting interrupt's trigger type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_INT_Trigger_LEVEL = 0x0, /**< This interrupt is level trigger */
|
||||
GPIO_INT_Trigger_EDGE = 0x1, /**< This interrupt is edge trigger */
|
||||
}GPIOIT_LevelType;
|
||||
|
||||
/**
|
||||
* @brief Setting interrupt active mode
|
||||
*
|
||||
* Setting interrupt active mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_INT_POLARITY_ACTIVE_LOW = 0x0, /**< Setting interrupt to low active: falling edge or low level */
|
||||
GPIO_INT_POLARITY_ACTIVE_HIGH = 0x1, /**< Setting interrupt to high active: rising edge or high level */
|
||||
}GPIOIT_PolarityType;
|
||||
|
||||
/**
|
||||
* @brief Enable/Disable interrupt debounce mode
|
||||
*
|
||||
* Enable/Disable interrupt debounce mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_INT_DEBOUNCE_DISABLE = 0x0, /**< Disable interrupt debounce */
|
||||
GPIO_INT_DEBOUNCE_ENABLE = 0x1, /**< Enable interrupt debounce */
|
||||
}GPIOIT_DebounceType;
|
||||
|
||||
|
||||
typedef struct {
|
||||
GPIOMode_TypeDef GPIO_Mode; /*!< Specifies the operating mode for the selected pins. */
|
||||
GPIOPuPd_TypeDef GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins. */
|
||||
GPIOIT_LevelType GPIO_ITTrigger; /**< Interrupt mode is level or edge trigger */
|
||||
GPIOIT_PolarityType GPIO_ITPolarity; /**< Interrupt mode is high or low active trigger */
|
||||
GPIOIT_DebounceType GPIO_ITDebounce; /**< Enable or disable de-bounce for interrupt */
|
||||
u32 GPIO_Pin; // Pin: [7:5]: port number, [4:0]: pin number
|
||||
}GPIO_InitTypeDef;
|
||||
#endif
|
||||
//======================================================
|
||||
|
||||
void example_uart_update();
|
||||
int is_update_image_enable(gpio_t *gpio_uart_update_eable);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue