forked from xuos/xiuos
				
			support e22 on stm32f4discovery
This commit is contained in:
		
						commit
						bcaf4ac6fc
					
				| 
						 | 
				
			
			@ -6,6 +6,10 @@ config ADAPTER_E220
 | 
			
		|||
        bool "Using lora adapter device E220-400T22S"
 | 
			
		||||
        default n
 | 
			
		||||
 | 
			
		||||
config ADAPTER_E22
 | 
			
		||||
        bool "Using lora adapter device E22-400T33D"
 | 
			
		||||
        default n
 | 
			
		||||
 | 
			
		||||
choice 
 | 
			
		||||
        prompt "Lora device adapter select net role type "
 | 
			
		||||
        default AS_LORA_CLIENT_ROLE
 | 
			
		||||
| 
						 | 
				
			
			@ -40,3 +44,7 @@ endif
 | 
			
		|||
if ADAPTER_E220
 | 
			
		||||
    source "$APP_DIR/Framework/connection/lora/e220/Kconfig"
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
if ADAPTER_E22
 | 
			
		||||
    source "$APP_DIR/Framework/connection/lora/e22/Kconfig"
 | 
			
		||||
endif 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,6 +28,10 @@ extern AdapterProductInfoType Sx1278Attach(struct Adapter *adapter);
 | 
			
		|||
extern AdapterProductInfoType E220Attach(struct Adapter *adapter);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef ADAPTER_E22
 | 
			
		||||
extern AdapterProductInfoType E22Attach(struct Adapter *adapter);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
//#define CLIENT_UPDATE_MODE
 | 
			
		||||
#define GATEWAY_CMD_MODE
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -887,6 +891,19 @@ int AdapterLoraInit(void)
 | 
			
		|||
    adapter->done = product_info->model_done;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef ADAPTER_E22
 | 
			
		||||
    AdapterProductInfoType product_info = E22Attach(adapter);
 | 
			
		||||
    if (!product_info) {
 | 
			
		||||
        printf("AdapterLoraInit e22 attach error\n");
 | 
			
		||||
        PrivFree(adapter);
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    adapter->product_info_flag = 1;
 | 
			
		||||
    adapter->info = product_info;
 | 
			
		||||
    adapter->done = product_info->model_done;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    PrivSemaphoreCreate(&adapter->sem, 0, 0);
 | 
			
		||||
 | 
			
		||||
    PrivSemaphoreCreate(&gateway_recv_data_sem, 0, 0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
config ADAPTER_LORA_E22
 | 
			
		||||
        string "E22-400T33D adapter name"
 | 
			
		||||
        default "e22"
 | 
			
		||||
 | 
			
		||||
if ADD_XIZI_FETURES
 | 
			
		||||
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
if ADD_NUTTX_FETURES
 | 
			
		||||
 | 
			
		||||
    config ADAPTER_E22_M0_PATH
 | 
			
		||||
        string "E22 M0 pin device"
 | 
			
		||||
        default "/dev/gpio0"
 | 
			
		||||
 | 
			
		||||
    config ADAPTER_E22_M1_PATH
 | 
			
		||||
        string "E22 M1 pin device"
 | 
			
		||||
        default "/dev/gpio1"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    config ADAPTER_E22_DRIVER
 | 
			
		||||
        string "E22 device uart driver path"
 | 
			
		||||
        default "/dev/ttyS3"
 | 
			
		||||
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
if ADD_RTTHREAD_FETURES
 | 
			
		||||
 | 
			
		||||
endif
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
############################################################################
 | 
			
		||||
# APP_Framework/Framework/connection/lora/e22/Make.defs
 | 
			
		||||
############################################################################
 | 
			
		||||
ifneq ($(CONFIG_ADAPTER_E22),)
 | 
			
		||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/lora/e22
 | 
			
		||||
endif
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
include $(KERNEL_ROOT)/.config
 | 
			
		||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
 | 
			
		||||
    include $(APPDIR)/Make.defs
 | 
			
		||||
    CSRCS += e22.c
 | 
			
		||||
    include $(APPDIR)/Application.mk
 | 
			
		||||
 | 
			
		||||
endif
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,509 @@
 | 
			
		|||
/*
 | 
			
		||||
* Copyright (c) 2020 AIIT XUOS Lab
 | 
			
		||||
* XiUOS is licensed under Mulan PSL v2.
 | 
			
		||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
 | 
			
		||||
* You may obtain a copy of Mulan PSL v2 at:
 | 
			
		||||
*        http://license.coscl.org.cn/MulanPSL2
 | 
			
		||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 | 
			
		||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 | 
			
		||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 | 
			
		||||
* See the Mulan PSL v2 for more details.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file e22.c
 | 
			
		||||
 * @brief Implement the connection E22-400T22S lora adapter function
 | 
			
		||||
 * @version 2.0
 | 
			
		||||
 * @author AIIT XUOS Lab
 | 
			
		||||
 * @date 2022.4.20
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <adapter.h>
 | 
			
		||||
 | 
			
		||||
#define E22_GATEWAY_ADDRESS 0xFFFF
 | 
			
		||||
#define E22_CHANNEL 0x05
 | 
			
		||||
 | 
			
		||||
#ifdef AS_LORA_GATEWAY_ROLE
 | 
			
		||||
#define E22_ADDRESS E22_GATEWAY_ADDRESS
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef AS_LORA_CLIENT_ROLE
 | 
			
		||||
#define E22_ADDRESS ADAPTER_LORA_NET_ROLE_ID
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define E22_UART_BAUD_RATE 115200
 | 
			
		||||
 | 
			
		||||
enum E22LoraMode
 | 
			
		||||
{
 | 
			
		||||
    DATA_TRANSFER_MODE = 0,  //M1 : M0 = 0 : 0
 | 
			
		||||
    WOR_SEND_MODE,           //M1 : M0 = 0 : 1
 | 
			
		||||
    CONFIGURE_MODE,          //M1 : M0 = 1 : 0
 | 
			
		||||
    SLEEP_MODE,              //M1 : M0 = 1 : 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: Config E22 work mode by set M1/M0 pin
 | 
			
		||||
 * @param mode Lora working mode
 | 
			
		||||
 * @return NULL
 | 
			
		||||
 */
 | 
			
		||||
static void E22LoraModeConfig(enum E22LoraMode mode)
 | 
			
		||||
{
 | 
			
		||||
    int m0_fd, m1_fd;
 | 
			
		||||
 | 
			
		||||
    //delay 1s , wait AUX ready
 | 
			
		||||
    PrivTaskDelay(1000);
 | 
			
		||||
    m0_fd = PrivOpen(ADAPTER_E22_M0_PATH, O_RDWR);
 | 
			
		||||
    if (m0_fd < 0) {
 | 
			
		||||
        printf("open %s error\n", ADAPTER_E22_M0_PATH);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    m1_fd = PrivOpen(ADAPTER_E22_M1_PATH, O_RDWR);
 | 
			
		||||
    if (m1_fd < 0) {
 | 
			
		||||
        printf("open %s error\n", ADAPTER_E22_M1_PATH);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //Both M0 and M1 GPIO are outputs mode, set M0 and M1 high or low
 | 
			
		||||
    switch (mode)
 | 
			
		||||
    {
 | 
			
		||||
    case DATA_TRANSFER_MODE:
 | 
			
		||||
        PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
 | 
			
		||||
        PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case WOR_SEND_MODE:
 | 
			
		||||
        PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
 | 
			
		||||
        PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
 | 
			
		||||
        break;
 | 
			
		||||
    
 | 
			
		||||
    case CONFIGURE_MODE:
 | 
			
		||||
        PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
 | 
			
		||||
        PrivIoctl(m0_fd, GPIOC_WRITE,(unsigned long)GPIO_LOW);
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case SLEEP_MODE:
 | 
			
		||||
        PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
 | 
			
		||||
        PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
 | 
			
		||||
        break;
 | 
			
		||||
    
 | 
			
		||||
    default:
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    PrivClose(m0_fd);
 | 
			
		||||
    PrivClose(m1_fd);
 | 
			
		||||
 | 
			
		||||
    //delay 20ms , wait mode switch done
 | 
			
		||||
    PrivTaskDelay(20);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: Switch baud rate to register bit
 | 
			
		||||
 * @param baud_rate - baud_rate
 | 
			
		||||
 * @return baud_rate_bit
 | 
			
		||||
 */
 | 
			
		||||
static uint8 E22BaudRateSwitch(uint32 baud_rate)
 | 
			
		||||
{
 | 
			
		||||
    uint8 baud_rate_bit;
 | 
			
		||||
 | 
			
		||||
    switch (baud_rate)
 | 
			
		||||
    {
 | 
			
		||||
    case 1200:
 | 
			
		||||
        baud_rate_bit = 0x0;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 2400:
 | 
			
		||||
        baud_rate_bit = 0x1;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 4800:
 | 
			
		||||
        baud_rate_bit = 0x2;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 9600:
 | 
			
		||||
        baud_rate_bit = 0x3;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 19200:
 | 
			
		||||
        baud_rate_bit = 0x4;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 38400:
 | 
			
		||||
        baud_rate_bit = 0x5;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 57600:
 | 
			
		||||
        baud_rate_bit = 0x6;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case 115200:
 | 
			
		||||
        baud_rate_bit = 0x7;
 | 
			
		||||
        break;
 | 
			
		||||
    
 | 
			
		||||
    default:
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return baud_rate_bit;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: Set E22 register, such as address、channel、baud rate...
 | 
			
		||||
 * @param adapter - lora adapter
 | 
			
		||||
 * @param address - address
 | 
			
		||||
 * @param channel - channel
 | 
			
		||||
 * @param baud_rate - baud_rate
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22SetRegisterParam(struct Adapter *adapter, uint16 address, uint8 channel, uint32 baud_rate)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
    uint8 buffer[50] = {0};
 | 
			
		||||
    uint8 baud_rate_bit = E22BaudRateSwitch(baud_rate);
 | 
			
		||||
 | 
			
		||||
    E22LoraModeConfig(CONFIGURE_MODE);
 | 
			
		||||
    PrivTaskDelay(30);
 | 
			
		||||
 | 
			
		||||
    buffer[0] = 0xC0;                   //write register order
 | 
			
		||||
    buffer[1] = 0x00;                   //register start-address
 | 
			
		||||
    buffer[2] = 0x09;                   //register length
 | 
			
		||||
 | 
			
		||||
    buffer[3] = (address >> 8) & 0xFF;  //high address
 | 
			
		||||
    buffer[4] = address & 0xFF;         //low adderss
 | 
			
		||||
 | 
			
		||||
    buffer[5] = 0x00;                   //net id
 | 
			
		||||
 | 
			
		||||
    buffer[6] = ((baud_rate_bit << 5) & 0xE0) | 0x04;  // baud、stop bits、air rate
 | 
			
		||||
 | 
			
		||||
    buffer[7] = 0x00;
 | 
			
		||||
    buffer[8] = channel;                 //channel
 | 
			
		||||
    buffer[9] = 0x03;
 | 
			
		||||
    buffer[10] = 0;                       //high-cipher
 | 
			
		||||
    buffer[11] = 0;                      //low-cipher
 | 
			
		||||
 | 
			
		||||
    ret = PrivWrite(adapter->fd, (void *)buffer, 12);
 | 
			
		||||
    if(ret < 0){
 | 
			
		||||
        printf("E22SetRegisterParam send failed %d!\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    PrivTaskDelay(1000);
 | 
			
		||||
    ret = PrivRead(adapter->fd, buffer, 19);
 | 
			
		||||
    if(ret < 0){
 | 
			
		||||
        printf("E22 RegisterParam get failed %d!\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    E22LoraModeConfig(DATA_TRANSFER_MODE);
 | 
			
		||||
    PrivTaskDelay(1000);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: Get E22 register, such as address、channel、baud rate...
 | 
			
		||||
 * @param buf - data buf
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22GetRegisterParam(uint8 *buf)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
    uint8 buffer[20] = {0};
 | 
			
		||||
 | 
			
		||||
    struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME);
 | 
			
		||||
    if (NULL == adapter) {
 | 
			
		||||
        printf("E22GetRegisterParam find lora adapter error\n");
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    E22LoraModeConfig(CONFIGURE_MODE);
 | 
			
		||||
    PrivTaskDelay(30);
 | 
			
		||||
 | 
			
		||||
    buffer[0] = 0xC1;                   //read register order
 | 
			
		||||
    buffer[1] = 0x00;                   //register start-address
 | 
			
		||||
    buffer[2] = 0x09;                   //register length
 | 
			
		||||
 | 
			
		||||
    ret = PrivWrite(adapter->fd, (void *)buffer, 3);
 | 
			
		||||
    if(ret < 0){
 | 
			
		||||
        printf("E22GetRegisterParam send failed %d!\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    PrivTaskDelay(1000);
 | 
			
		||||
    ret = PrivRead(adapter->fd, buf, 19);
 | 
			
		||||
    if(ret < 0){
 | 
			
		||||
        printf("E22 RegisterParam get failed %d!\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    E22LoraModeConfig(DATA_TRANSFER_MODE);
 | 
			
		||||
    PrivTaskDelay(1000);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: Open E22 uart function
 | 
			
		||||
 * @param adapter - Lora device pointer
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22Open(struct Adapter *adapter)
 | 
			
		||||
{
 | 
			
		||||
    int ret = 0;
 | 
			
		||||
    struct termios cfg;
 | 
			
		||||
    /*step1: open e22 uart port*/
 | 
			
		||||
    adapter->fd = PrivOpen(ADAPTER_E22_DRIVER, O_RDWR);
 | 
			
		||||
    if (adapter->fd < 0) {
 | 
			
		||||
        printf("E22Open get uart %s fd error\n", ADAPTER_E22_DRIVER);
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tcgetattr(adapter->fd, &cfg);
 | 
			
		||||
    cfsetspeed(&cfg, BAUD_RATE_9600);
 | 
			
		||||
    tcsetattr(adapter->fd, TCSANOW, &cfg);
 | 
			
		||||
 | 
			
		||||
    E22SetRegisterParam(adapter, E22_ADDRESS, E22_CHANNEL, E22_UART_BAUD_RATE);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    cfsetspeed(&cfg, E22_UART_BAUD_RATE);
 | 
			
		||||
    tcsetattr(adapter->fd, TCSANOW, &cfg);
 | 
			
		||||
 | 
			
		||||
    ADAPTER_DEBUG("E22Open done\n");
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: Close E22 uart function
 | 
			
		||||
 * @param adapter - Lora device pointer
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22Close(struct Adapter *adapter)
 | 
			
		||||
{
 | 
			
		||||
    /*step1: close e22 uart port*/
 | 
			
		||||
    int ret;
 | 
			
		||||
    ret = PrivClose(adapter->fd);
 | 
			
		||||
    if(ret < 0) {
 | 
			
		||||
        printf("E22 close failed: %d!\n", ret);
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ADAPTER_DEBUG("E22 Close done\n");
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: E22 ioctl function
 | 
			
		||||
 * @param adapter - Lora device pointer
 | 
			
		||||
 * @param cmd - ioctl cmd
 | 
			
		||||
 * @param args - iotl params
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22Ioctl(struct Adapter *adapter, int cmd, void *args)
 | 
			
		||||
{
 | 
			
		||||
    /*to do*/
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: E22 join lora net group function
 | 
			
		||||
 * @param adapter - Lora device pointer
 | 
			
		||||
 * @param priv_net_group - priv_net_group params
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22Join(struct Adapter *adapter, unsigned char *priv_net_group)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
    struct AdapterData *priv_net_group_data = (struct AdapterData *)priv_net_group;
 | 
			
		||||
 | 
			
		||||
    ret = PrivWrite(adapter->fd, (void *)priv_net_group_data->buffer, priv_net_group_data->len);
 | 
			
		||||
    if(ret < 0) {
 | 
			
		||||
        printf("E22 Join net group failed: %d!\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: E22 send data function
 | 
			
		||||
 * @param adapter - Lora device pointer
 | 
			
		||||
 * @param buf - data buffers
 | 
			
		||||
 * @param len - data len
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22Send(struct Adapter *adapter, const void *buf, size_t len)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    ret = PrivWrite(adapter->fd, (void *)buf, len);
 | 
			
		||||
    if(ret < 0){
 | 
			
		||||
        printf("send failed %d!\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: E22 receive data function 
 | 
			
		||||
 * @param adapter - Lora device pointer
 | 
			
		||||
 * @param buf - data buffers
 | 
			
		||||
 * @param len - data len
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22Recv(struct Adapter *adapter, void *buf, size_t len)
 | 
			
		||||
{
 | 
			
		||||
    int recv_len, recv_len_continue;
 | 
			
		||||
 | 
			
		||||
    uint8 *recv_buf = PrivMalloc(len);
 | 
			
		||||
 | 
			
		||||
    recv_len = PrivRead(adapter->fd, recv_buf, len);
 | 
			
		||||
    if (recv_len) {
 | 
			
		||||
        while (recv_len < len) {
 | 
			
		||||
            recv_len_continue = PrivRead(adapter->fd, recv_buf + recv_len, len - recv_len);
 | 
			
		||||
            if (recv_len_continue) {
 | 
			
		||||
                recv_len += recv_len_continue;
 | 
			
		||||
            } else {
 | 
			
		||||
                recv_len = 0;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        memcpy(buf, recv_buf, len);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    PrivFree(recv_buf);
 | 
			
		||||
    
 | 
			
		||||
    return recv_len;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @description: E22 quit lora net group function
 | 
			
		||||
 * @param adapter - Lora device pointer
 | 
			
		||||
 * @param priv_net_group - priv_net_group params
 | 
			
		||||
 * @return success: 0, failure: -1
 | 
			
		||||
 */
 | 
			
		||||
static int E22Quit(struct Adapter *adapter, unsigned char *priv_net_group)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    struct AdapterData *priv_net_group_data = (struct AdapterData *)priv_net_group;
 | 
			
		||||
 | 
			
		||||
    ret = PrivWrite(adapter->fd, (void *)priv_net_group_data->buffer, priv_net_group_data->len);
 | 
			
		||||
    if(ret < 0){
 | 
			
		||||
        printf("E22 quit net group failed %d!\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const struct PrivProtocolDone e22_done = 
 | 
			
		||||
{
 | 
			
		||||
    .open = E22Open,
 | 
			
		||||
    .close = E22Close,
 | 
			
		||||
    .ioctl = E22Ioctl,
 | 
			
		||||
    .setup = NULL,
 | 
			
		||||
    .setdown = NULL,
 | 
			
		||||
    .setaddr = NULL,
 | 
			
		||||
    .setdns = NULL,
 | 
			
		||||
    .setdhcp = NULL,
 | 
			
		||||
    .ping = NULL,
 | 
			
		||||
    .netstat = NULL,
 | 
			
		||||
    .join = E22Join,
 | 
			
		||||
    .send = E22Send,
 | 
			
		||||
    .recv = E22Recv,
 | 
			
		||||
    .quit = E22Quit,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
AdapterProductInfoType E22Attach(struct Adapter *adapter)
 | 
			
		||||
{
 | 
			
		||||
    struct AdapterProductInfo *product_info = malloc(sizeof(struct AdapterProductInfo));
 | 
			
		||||
    if (!product_info) {
 | 
			
		||||
        printf("E22Attach malloc product_info error\n");
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    strncpy(product_info->model_name, ADAPTER_LORA_E22,sizeof(product_info->model_name));
 | 
			
		||||
    product_info->model_done = (void *)&e22_done;
 | 
			
		||||
 | 
			
		||||
    return product_info;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//###################TEST####################
 | 
			
		||||
static void LoraOpen(void)
 | 
			
		||||
{
 | 
			
		||||
    struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME);
 | 
			
		||||
    if (NULL == adapter) {
 | 
			
		||||
        printf("LoraReceive find lora adapter error\n");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    E22Open(adapter);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void LoraRead(void *parameter)
 | 
			
		||||
{
 | 
			
		||||
	int RevLen;
 | 
			
		||||
	int i, cnt = 0;
 | 
			
		||||
 | 
			
		||||
    uint8 buffer[256];
 | 
			
		||||
 | 
			
		||||
    memset(buffer, 0, 256);
 | 
			
		||||
 | 
			
		||||
    struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME);
 | 
			
		||||
    if (NULL == adapter) {
 | 
			
		||||
        printf("LoraRead find lora adapter error\n");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
	
 | 
			
		||||
    while (1)
 | 
			
		||||
    {
 | 
			
		||||
        printf("ready to read lora data\n");
 | 
			
		||||
 | 
			
		||||
        RevLen = E22Recv(adapter, buffer, 256);
 | 
			
		||||
		if (RevLen) {
 | 
			
		||||
            printf("lora get data %u\n", RevLen);
 | 
			
		||||
            for (i = 0; i < RevLen; i ++) {
 | 
			
		||||
                printf("i %u data 0x%x\n", i, buffer[i]);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            memset(buffer, 0, 256);
 | 
			
		||||
 | 
			
		||||
            PrivTaskDelay(1000);
 | 
			
		||||
 | 
			
		||||
			cnt ++;
 | 
			
		||||
            E22Send(adapter, &cnt, 1);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void E22LoraReceive(void)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
    pthread_t thread; 
 | 
			
		||||
    pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
 | 
			
		||||
    attr.priority = 80;
 | 
			
		||||
    attr.stacksize = 2048;
 | 
			
		||||
 | 
			
		||||
    LoraOpen(); 
 | 
			
		||||
 | 
			
		||||
    ret = PrivTaskCreate(&thread, &attr, (void*)LoraRead, NULL);
 | 
			
		||||
    if (ret < 0) {
 | 
			
		||||
        printf("task lora read create failed, status=%d\n", ret);
 | 
			
		||||
		return;
 | 
			
		||||
	} 
 | 
			
		||||
}
 | 
			
		||||
void E22LoraSend(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
    struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME);
 | 
			
		||||
    if (NULL == adapter) {
 | 
			
		||||
        printf("LoraRead find lora adapter error\n");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (argc == 2) {
 | 
			
		||||
        char Msg[256] = {0};
 | 
			
		||||
        strncpy(Msg, argv[1], 256);
 | 
			
		||||
 | 
			
		||||
        E22Open(adapter);
 | 
			
		||||
        E22Send(adapter, Msg, strlen(Msg));
 | 
			
		||||
        E22Close(adapter);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
#
 | 
			
		||||
# For a description of the syntax of this configuration file,
 | 
			
		||||
# see the file kconfig-language.txt in the NuttX tools repository.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
config EXAMPLES_E22
 | 
			
		||||
	tristate "E22 driver example"
 | 
			
		||||
	default n
 | 
			
		||||
	depends on STM32_USART3
 | 
			
		||||
	---help---
 | 
			
		||||
		Enable the e22 driver example
 | 
			
		||||
 | 
			
		||||
if EXAMPLES_E22
 | 
			
		||||
 | 
			
		||||
config EXAMPLES_E22_PROGNAME
 | 
			
		||||
	string "Program name"
 | 
			
		||||
	default "e22"
 | 
			
		||||
	---help---
 | 
			
		||||
		This is the name of the program that will be used when the NSH ELF
 | 
			
		||||
		program is installed.
 | 
			
		||||
 | 
			
		||||
config EXAMPLES_E22_PRIORITY
 | 
			
		||||
	int "E22 task priority"
 | 
			
		||||
	default 100
 | 
			
		||||
 | 
			
		||||
config EXAMPLES_E22_STACKSIZE
 | 
			
		||||
	int "E22 stack size"
 | 
			
		||||
	default DEFAULT_TASK_STACKSIZE
 | 
			
		||||
 | 
			
		||||
endif
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
############################################################################
 | 
			
		||||
# apps/examples/gpio/Make.defs
 | 
			
		||||
#
 | 
			
		||||
# Licensed to the Apache Software Foundation (ASF) under one or more
 | 
			
		||||
# contributor license agreements.  See the NOTICE file distributed with
 | 
			
		||||
# this work for additional information regarding copyright ownership.  The
 | 
			
		||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
 | 
			
		||||
# "License"); you may not use this file except in compliance with the
 | 
			
		||||
# License.  You may obtain a copy of the License at
 | 
			
		||||
#
 | 
			
		||||
#   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 | 
			
		||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 | 
			
		||||
# License for the specific language governing permissions and limitations
 | 
			
		||||
# under the License.
 | 
			
		||||
#
 | 
			
		||||
############################################################################
 | 
			
		||||
 | 
			
		||||
ifneq ($(CONFIG_EXAMPLES_E22),)
 | 
			
		||||
CONFIGURED_APPS += $(APPDIR)/examples/e22_demo
 | 
			
		||||
endif
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
############################################################################
 | 
			
		||||
# apps/examples/gpio/Makefile
 | 
			
		||||
#
 | 
			
		||||
# Licensed to the Apache Software Foundation (ASF) under one or more
 | 
			
		||||
# contributor license agreements.  See the NOTICE file distributed with
 | 
			
		||||
# this work for additional information regarding copyright ownership.  The
 | 
			
		||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
 | 
			
		||||
# "License"); you may not use this file except in compliance with the
 | 
			
		||||
# License.  You may obtain a copy of the License at
 | 
			
		||||
#
 | 
			
		||||
#   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 | 
			
		||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 | 
			
		||||
# License for the specific language governing permissions and limitations
 | 
			
		||||
# under the License.
 | 
			
		||||
#
 | 
			
		||||
############################################################################
 | 
			
		||||
 | 
			
		||||
include $(APPDIR)/Make.defs
 | 
			
		||||
 | 
			
		||||
# GPIO, World! built-in application info
 | 
			
		||||
 | 
			
		||||
PROGNAME = $(CONFIG_EXAMPLES_E22_PROGNAME)
 | 
			
		||||
PRIORITY = $(CONFIG_EXAMPLES_E22_PRIORITY)
 | 
			
		||||
STACKSIZE = $(CONFIG_EXAMPLES_E22_STACKSIZE)
 | 
			
		||||
MODULE = $(CONFIG_EXAMPLES_E22)
 | 
			
		||||
 | 
			
		||||
# GPIO, World! Example
 | 
			
		||||
 | 
			
		||||
MAINSRC = e22_main.c
 | 
			
		||||
 | 
			
		||||
include $(APPDIR)/Application.mk
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,109 @@
 | 
			
		|||
/*
 | 
			
		||||
* Copyright (c) 2020 AIIT XUOS Lab
 | 
			
		||||
* XiOS is licensed under Mulan PSL v2.
 | 
			
		||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
 | 
			
		||||
* You may obtain a copy of Mulan PSL v2 at:
 | 
			
		||||
*        http://license.coscl.org.cn/MulanPSL2
 | 
			
		||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 | 
			
		||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 | 
			
		||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 | 
			
		||||
* See the Mulan PSL v2 for more details.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file e22_main.c
 | 
			
		||||
 * @brief e22 demo
 | 
			
		||||
 * @version 1.0
 | 
			
		||||
 * @author AIIT XUOS Lab
 | 
			
		||||
 * @date 2022.05.20
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Included Files
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
#include <nuttx/config.h>
 | 
			
		||||
 | 
			
		||||
#include <sys/ioctl.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <termios.h>
 | 
			
		||||
#include <nuttx/ioexpander/gpio.h>
 | 
			
		||||
 | 
			
		||||
int main(int argc, FAR char *argv[])
 | 
			
		||||
{
 | 
			
		||||
    int fd, m0fd, m1fd;
 | 
			
		||||
    int ret;
 | 
			
		||||
    int i;
 | 
			
		||||
    struct termios tio;
 | 
			
		||||
 | 
			
		||||
    char sendbuffer1[4] = {0xC0,0x05,0x01,0x09};
 | 
			
		||||
    char sendbuffer2[7] = {0xC0,0x00,0x04,0x12,0x34,0x00,0x61};
 | 
			
		||||
    char sendbuffer3[3] = {0xC1,0x00,0x04};
 | 
			
		||||
    char buffer[256];
 | 
			
		||||
    int readlen;
 | 
			
		||||
 | 
			
		||||
    fd = open("/dev/ttyS3", O_RDWR);
 | 
			
		||||
    if(fd < 0)
 | 
			
		||||
    {
 | 
			
		||||
      printf("Error opening serial: %d\n", fd);;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    ret = tcgetattr(fd, &tio);
 | 
			
		||||
    if (ret < 0)
 | 
			
		||||
    {
 | 
			
		||||
        printf("Error getting attributes: %d\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    ret = cfsetspeed(&tio, B9600);
 | 
			
		||||
    if (ret < 0)
 | 
			
		||||
    {
 | 
			
		||||
        printf("Error setting baud rate: %d\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    ret = tcsetattr(fd, TCSANOW, &tio);
 | 
			
		||||
    if (ret < 0)
 | 
			
		||||
    {
 | 
			
		||||
        printf("Error getting attributes: %d\n", ret);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    m0fd = open("/dev/gpout0", O_RDWR);
 | 
			
		||||
    m1fd = open("/dev/gpout1", O_RDWR);
 | 
			
		||||
    ioctl(m0fd, GPIOC_WRITE, (unsigned long)0);
 | 
			
		||||
    ioctl(m1fd, GPIOC_WRITE, (unsigned long)1);
 | 
			
		||||
    sleep(1);
 | 
			
		||||
 | 
			
		||||
    write(fd, sendbuffer1,4);
 | 
			
		||||
    sleep(1);
 | 
			
		||||
    readlen = read(fd, buffer, 256);
 | 
			
		||||
    printf("readlen1 = %d\n", readlen);
 | 
			
		||||
    for(i = 0;i< readlen; ++i)
 | 
			
		||||
    {
 | 
			
		||||
        printf("0x%x\n", buffer[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    write(fd, sendbuffer2,7);
 | 
			
		||||
    sleep(1);
 | 
			
		||||
    readlen = read(fd, buffer, 256);
 | 
			
		||||
    printf("readlen1 = %d\n", readlen);
 | 
			
		||||
    for(i = 0;i< readlen; ++i)
 | 
			
		||||
    {
 | 
			
		||||
        printf("0x%x\n", buffer[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    write(fd, sendbuffer3,3);
 | 
			
		||||
    sleep(1);
 | 
			
		||||
    readlen = read(fd, buffer, 256);
 | 
			
		||||
    printf("readlen1 = %d\n", readlen);
 | 
			
		||||
    for(i = 0;i< readlen; ++i)
 | 
			
		||||
    {
 | 
			
		||||
        printf("0x%x\n", buffer[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    close(fd);
 | 
			
		||||
    close(m0fd);
 | 
			
		||||
    close(m1fd);
 | 
			
		||||
    
 | 
			
		||||
    return 0;  
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -635,6 +635,14 @@ config NSH_DISABLE_E220_LORA_SEND
 | 
			
		|||
	bool "Disable e220 Lora send."
 | 
			
		||||
	default n
 | 
			
		||||
 | 
			
		||||
config NSH_DISABLE_E22_LORA_RECEIVE
 | 
			
		||||
	bool "Disable e22 Lora receive."
 | 
			
		||||
	default n
 | 
			
		||||
 | 
			
		||||
config NSH_DISABLE_E22_LORA_SEND
 | 
			
		||||
	bool "Disable e22 Lora send."
 | 
			
		||||
	default n
 | 
			
		||||
 | 
			
		||||
config NSH_DISABLE_ADAPTER_BLUETOOTH_TEST
 | 
			
		||||
	bool "Disable hc08  AdapterBlueToothTest."
 | 
			
		||||
	default n
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1527,7 +1527,8 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
 | 
			
		|||
  int cmd_recvzigbee(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if (defined(CONFIG_ADAPTER_LORA_SX1278) || defined(CONFIG_ADAPTER_LORA_E220)) && !defined(CONFIG_NSH_DISABLE_ADAPTER_LORATEST)
 | 
			
		||||
#if (defined(CONFIG_ADAPTER_LORA_SX1278) || defined(CONFIG_ADAPTER_LORA_E220) || defined(CONFIG_ADAPTER_LORA_E22)) && \
 | 
			
		||||
    !defined(CONFIG_NSH_DISABLE_ADAPTER_LORATEST)
 | 
			
		||||
  int cmd_AdapterLoraTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1543,6 +1544,14 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
 | 
			
		|||
  int cmd_E220LoraSend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_LORA_E22) && !defined(CONFIG_NSH_DISABLE_E22_LORA_RECEIVE)
 | 
			
		||||
  int cmd_E22LoraReceive(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_LORA_E22) && !defined(CONFIG_NSH_DISABLE_E22_LORA_SEND)
 | 
			
		||||
  int cmd_E22LoraSend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_BLUETOOTH_HC08) && !defined(CONFIG_NSH_DISABLE_ADAPTER_BLUETOOTH_TEST)
 | 
			
		||||
  int cmd_AdapterBlueToothTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -322,7 +322,8 @@ int cmd_AdapterWifiTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
 | 
			
		|||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if (defined(CONFIG_ADAPTER_LORA_SX1278) || defined(CONFIG_ADAPTER_LORA_E220)) && !defined(CONFIG_NSH_DISABLE_ADAPTER_LORATEST)
 | 
			
		||||
#if (defined(CONFIG_ADAPTER_LORA_SX1278) || defined(CONFIG_ADAPTER_LORA_E220) || defined(CONFIG_ADAPTER_LORA_E22)) && \
 | 
			
		||||
    !defined(CONFIG_NSH_DISABLE_ADAPTER_LORATEST)
 | 
			
		||||
extern int AdapterLoraTest(void);
 | 
			
		||||
int cmd_AdapterLoraTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -366,6 +367,28 @@ int cmd_E220LoraSend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
 | 
			
		|||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_LORA_E22) && !defined(CONFIG_NSH_DISABLE_E22_LORA_RECEIVE)
 | 
			
		||||
void E22LoraReceive(void);
 | 
			
		||||
int cmd_E22LoraReceive(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
    nsh_output(vtbl, "Hello, world!\n");
 | 
			
		||||
    FrameworkInit();
 | 
			
		||||
    E22LoraReceive();
 | 
			
		||||
    return OK;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_LORA_E22) && !defined(CONFIG_NSH_DISABLE_E22_LORA_SEND)
 | 
			
		||||
extern void E22LoraSend(int argc, char *argv[]);
 | 
			
		||||
int cmd_E22LoraSend(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
    nsh_output(vtbl, "Hello, world!\n");
 | 
			
		||||
    FrameworkInit();
 | 
			
		||||
    E22LoraSend(argc,argv);
 | 
			
		||||
    return OK;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_BLUETOOTH_HC08) && !defined(CONFIG_NSH_DISABLE_ADAPTER_BLUETOOTH_TEST)
 | 
			
		||||
extern int AdapterBlueToothTest(void);
 | 
			
		||||
int cmd_AdapterBlueToothTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -672,8 +672,9 @@ static const struct cmdmap_s g_cmdmap[] =
 | 
			
		|||
  { "recvzigbee",       cmd_recvzigbee,       1, 1, "[receive message.]" },
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if (defined(CONFIG_ADAPTER_LORA_SX1278) || defined(CONFIG_ADAPTER_LORA_E220)) && !defined(CONFIG_NSH_DISABLE_ADAPTER_LORATEST)
 | 
			
		||||
  { "AdapterLoraTest",       cmd_AdapterLoraTest,       1, 1, "[Lora sx128 test.]" },
 | 
			
		||||
#if (defined(CONFIG_ADAPTER_LORA_SX1278) || defined(CONFIG_ADAPTER_LORA_E220) || defined(CONFIG_ADAPTER_LORA_E22)) && \
 | 
			
		||||
    !defined(CONFIG_NSH_DISABLE_ADAPTER_LORATEST)
 | 
			
		||||
  { "AdapterLoraTest",       cmd_AdapterLoraTest,       1, 1, "[Lora test.]" },
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_4G_EC200T) && !defined(CONFIG_NSH_DISABLE_ADAPTER_4GTEST)
 | 
			
		||||
| 
						 | 
				
			
			@ -688,6 +689,14 @@ static const struct cmdmap_s g_cmdmap[] =
 | 
			
		|||
  { "E220Send",       cmd_E220LoraSend,       1, 2, "[e220loraSend <message>]" },
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_LORA_E22) && !defined(CONFIG_NSH_DISABLE_E22_LORA_RECEIVE)
 | 
			
		||||
  { "E22Receive",       cmd_E22LoraReceive,       1, 1, "[e22 lora receive.]" },
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_LORA_E22) && !defined(CONFIG_NSH_DISABLE_E22_LORA_SEND)
 | 
			
		||||
  { "E22Send",       cmd_E22LoraSend,       1, 2, "[e22loraSend <message>]" },
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_ADAPTER_BLUETOOTH_HC08) && !defined(CONFIG_NSH_DISABLE_ADAPTER_BLUETOOTH_TEST)
 | 
			
		||||
  { "AdapterBlueToothTest",       cmd_AdapterBlueToothTest,       1, 1, "[BlueTooth hc08 test.]" },
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,68 @@
 | 
			
		|||
#
 | 
			
		||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
 | 
			
		||||
#
 | 
			
		||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
 | 
			
		||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
 | 
			
		||||
# modifications.
 | 
			
		||||
#
 | 
			
		||||
# CONFIG_ARCH_FPU is not set
 | 
			
		||||
# CONFIG_NSH_ARGCAT is not set
 | 
			
		||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
 | 
			
		||||
# CONFIG_NSH_CMDPARMS is not set
 | 
			
		||||
CONFIG_ADD_NUTTX_FETURES=y
 | 
			
		||||
CONFIG_ARCH="arm"
 | 
			
		||||
CONFIG_ARCH_BOARD="stm32f4discovery"
 | 
			
		||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
 | 
			
		||||
CONFIG_ARCH_BUTTONS=y
 | 
			
		||||
CONFIG_ARCH_CHIP="stm32"
 | 
			
		||||
CONFIG_ARCH_CHIP_STM32=y
 | 
			
		||||
CONFIG_ARCH_CHIP_STM32F407VG=y
 | 
			
		||||
CONFIG_ARCH_STACKDUMP=y
 | 
			
		||||
CONFIG_BOARD_LATE_INITIALIZE=y
 | 
			
		||||
CONFIG_BOARD_LOOPSPERMSEC=16717
 | 
			
		||||
CONFIG_BUILTIN=y
 | 
			
		||||
CONFIG_EXAMPLES_HELLO=y
 | 
			
		||||
CONFIG_FS_PROCFS=y
 | 
			
		||||
CONFIG_HAVE_CXX=y
 | 
			
		||||
CONFIG_HAVE_CXXINITIALIZE=y
 | 
			
		||||
CONFIG_HOST_WINDOWS=y
 | 
			
		||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
 | 
			
		||||
CONFIG_INTELHEX_BINARY=y
 | 
			
		||||
CONFIG_MM_REGIONS=2
 | 
			
		||||
CONFIG_NSH_BUILTIN_APPS=y
 | 
			
		||||
CONFIG_NSH_FILEIOSIZE=512
 | 
			
		||||
CONFIG_NSH_LINELEN=64
 | 
			
		||||
CONFIG_NSH_READLINE=y
 | 
			
		||||
CONFIG_PREALLOC_TIMERS=4
 | 
			
		||||
CONFIG_RAM_SIZE=114688
 | 
			
		||||
CONFIG_RAM_START=0x20000000
 | 
			
		||||
CONFIG_RAW_BINARY=y
 | 
			
		||||
CONFIG_RR_INTERVAL=200
 | 
			
		||||
CONFIG_SCHED_WAITPID=y
 | 
			
		||||
CONFIG_START_DAY=6
 | 
			
		||||
CONFIG_START_MONTH=12
 | 
			
		||||
CONFIG_START_YEAR=2011
 | 
			
		||||
CONFIG_STM32_JTAG_SW_ENABLE=y
 | 
			
		||||
CONFIG_STM32_PWR=y
 | 
			
		||||
CONFIG_STM32_SPI1=y
 | 
			
		||||
CONFIG_STM32_USART2=y
 | 
			
		||||
CONFIG_STM32_USART3=y
 | 
			
		||||
CONFIG_SERIAL_TERMIOS=y
 | 
			
		||||
CONFIG_SYSTEM_NSH=y
 | 
			
		||||
CONFIG_USART2_RXBUFSIZE=128
 | 
			
		||||
CONFIG_USART2_SERIAL_CONSOLE=y
 | 
			
		||||
CONFIG_USART2_TXBUFSIZE=128
 | 
			
		||||
CONFIG_DEV_GPIO=y
 | 
			
		||||
CONFIG_BOARDCTL_RESET=y
 | 
			
		||||
CONFIG_READLINE_CMD_HISTORY=y
 | 
			
		||||
CONFIG_READLINE_CMD_HISTORY_LEN=100
 | 
			
		||||
CONFIG_READLINE_CMD_HISTORY_LINELEN=120
 | 
			
		||||
CONFIG_READLINE_TABCOMPLETION=y
 | 
			
		||||
CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y
 | 
			
		||||
CONFIG_CONNECTION_FRAMEWORK_DEBUG=y
 | 
			
		||||
CONFIG_CONNECTION_ADAPTER_LORA=y
 | 
			
		||||
CONFIG_ADAPTER_E22=y
 | 
			
		||||
CONFIG_ADAPTER_LORA_E22="e22"
 | 
			
		||||
CONFIG_ADAPTER_E22_M0_PATH="/dev/gpio0"
 | 
			
		||||
CONFIG_ADAPTER_E22_M1_PATH="/dev/gpio1"
 | 
			
		||||
CONFIG_ADAPTER_E22_DRIVER="/dev/ttyS3"
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,60 @@
 | 
			
		|||
#
 | 
			
		||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
 | 
			
		||||
#
 | 
			
		||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
 | 
			
		||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
 | 
			
		||||
# modifications.
 | 
			
		||||
#
 | 
			
		||||
# CONFIG_ARCH_FPU is not set
 | 
			
		||||
# CONFIG_NSH_ARGCAT is not set
 | 
			
		||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
 | 
			
		||||
# CONFIG_NSH_CMDPARMS is not set
 | 
			
		||||
CONFIG_ADD_NUTTX_FETURES=y
 | 
			
		||||
CONFIG_ARCH="arm"
 | 
			
		||||
CONFIG_ARCH_BOARD="stm32f4discovery"
 | 
			
		||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
 | 
			
		||||
CONFIG_ARCH_BUTTONS=y
 | 
			
		||||
CONFIG_ARCH_CHIP="stm32"
 | 
			
		||||
CONFIG_ARCH_CHIP_STM32=y
 | 
			
		||||
CONFIG_ARCH_CHIP_STM32F407VG=y
 | 
			
		||||
CONFIG_ARCH_STACKDUMP=y
 | 
			
		||||
CONFIG_BOARD_LATE_INITIALIZE=y
 | 
			
		||||
CONFIG_BOARD_LOOPSPERMSEC=16717
 | 
			
		||||
CONFIG_BUILTIN=y
 | 
			
		||||
CONFIG_EXAMPLES_HELLO=y
 | 
			
		||||
CONFIG_FS_PROCFS=y
 | 
			
		||||
CONFIG_HAVE_CXX=y
 | 
			
		||||
CONFIG_HAVE_CXXINITIALIZE=y
 | 
			
		||||
CONFIG_HOST_WINDOWS=y
 | 
			
		||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
 | 
			
		||||
CONFIG_INTELHEX_BINARY=y
 | 
			
		||||
CONFIG_MM_REGIONS=2
 | 
			
		||||
CONFIG_NSH_BUILTIN_APPS=y
 | 
			
		||||
CONFIG_NSH_FILEIOSIZE=512
 | 
			
		||||
CONFIG_NSH_LINELEN=64
 | 
			
		||||
CONFIG_NSH_READLINE=y
 | 
			
		||||
CONFIG_PREALLOC_TIMERS=4
 | 
			
		||||
CONFIG_RAM_SIZE=114688
 | 
			
		||||
CONFIG_RAM_START=0x20000000
 | 
			
		||||
CONFIG_RAW_BINARY=y
 | 
			
		||||
CONFIG_RR_INTERVAL=200
 | 
			
		||||
CONFIG_SCHED_WAITPID=y
 | 
			
		||||
CONFIG_START_DAY=6
 | 
			
		||||
CONFIG_START_MONTH=12
 | 
			
		||||
CONFIG_START_YEAR=2011
 | 
			
		||||
CONFIG_STM32_JTAG_SW_ENABLE=y
 | 
			
		||||
CONFIG_STM32_PWR=y
 | 
			
		||||
CONFIG_STM32_SPI1=y
 | 
			
		||||
CONFIG_STM32_USART2=y
 | 
			
		||||
CONFIG_STM32_USART3=y
 | 
			
		||||
CONFIG_SERIAL_TERMIOS=y
 | 
			
		||||
CONFIG_SYSTEM_NSH=y
 | 
			
		||||
CONFIG_USART2_RXBUFSIZE=128
 | 
			
		||||
CONFIG_USART2_SERIAL_CONSOLE=y
 | 
			
		||||
CONFIG_USART2_TXBUFSIZE=128
 | 
			
		||||
CONFIG_DEV_GPIO=y
 | 
			
		||||
CONFIG_BOARDCTL_RESET=y
 | 
			
		||||
CONFIG_READLINE_CMD_HISTORY=y
 | 
			
		||||
CONFIG_READLINE_CMD_HISTORY_LEN=100
 | 
			
		||||
CONFIG_READLINE_CMD_HISTORY_LINELEN=120
 | 
			
		||||
CONFIG_READLINE_TABCOMPLETION=y
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,184 @@
 | 
			
		|||
############################################################################
 | 
			
		||||
# boards/arm/stm32/stm32f4discovery/src/Make.defs
 | 
			
		||||
#
 | 
			
		||||
# Licensed to the Apache Software Foundation (ASF) under one or more
 | 
			
		||||
# contributor license agreements.  See the NOTICE file distributed with
 | 
			
		||||
# this work for additional information regarding copyright ownership.  The
 | 
			
		||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
 | 
			
		||||
# "License"); you may not use this file except in compliance with the
 | 
			
		||||
# License.  You may obtain a copy of the License at
 | 
			
		||||
#
 | 
			
		||||
#   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
#
 | 
			
		||||
# Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 | 
			
		||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 | 
			
		||||
# License for the specific language governing permissions and limitations
 | 
			
		||||
# under the License.
 | 
			
		||||
#
 | 
			
		||||
############################################################################
 | 
			
		||||
 | 
			
		||||
include $(TOPDIR)/Make.defs
 | 
			
		||||
 | 
			
		||||
CSRCS = stm32_boot.c stm32_bringup.c stm32_spi.c stm32_perfcount.c
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_ARCH_LEDS),y)
 | 
			
		||||
CSRCS += stm32_autoleds.c
 | 
			
		||||
else
 | 
			
		||||
CSRCS += stm32_userleds.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_AUDIO_CS43L22),y)
 | 
			
		||||
CSRCS += stm32_cs43l22.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_ARCH_BUTTONS),y)
 | 
			
		||||
CSRCS +=  stm32_buttons.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_STM32_CAN_CHARDRIVER),y)
 | 
			
		||||
CSRCS += stm32_can.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_STM32_OTGFS),y)
 | 
			
		||||
CSRCS += stm32_usb.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_ST7567),y)
 | 
			
		||||
CSRCS += stm32_st7567.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_ENC28J60),y)
 | 
			
		||||
CSRCS += stm32_enc28j60.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LPWAN_SX127X),y)
 | 
			
		||||
CSRCS += stm32_sx127x.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_MAX7219),y)
 | 
			
		||||
CSRCS += stm32_max7219.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_ST7032),y)
 | 
			
		||||
CSRCS += stm32_st7032.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_PCA9635PW),y)
 | 
			
		||||
CSRCS += stm32_pca9635.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_STM32_SDIO),y)
 | 
			
		||||
CSRCS += stm32_sdio.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_STM32_ETHMAC),y)
 | 
			
		||||
CSRCS += stm32_ethernet.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LEDS_MAX7219),y)
 | 
			
		||||
CSRCS += stm32_max7219_leds.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_RGBLED),y)
 | 
			
		||||
CSRCS += stm32_rgbled.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_RTC_DS1307),y)
 | 
			
		||||
CSRCS += stm32_ds1307.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_PWM),y)
 | 
			
		||||
CSRCS += stm32_pwm.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_BOARDCTL),y)
 | 
			
		||||
CSRCS += stm32_appinit.c
 | 
			
		||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
 | 
			
		||||
CSRCS += stm32_reset.c
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_ARCH_CUSTOM_PMINIT),y)
 | 
			
		||||
CSRCS += stm32_pm.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_PM_BUTTONS),y)
 | 
			
		||||
CSRCS += stm32_pmbuttons.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_ARCH_IDLE_CUSTOM),y)
 | 
			
		||||
CSRCS += stm32_idle.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_STM32_FSMC),y)
 | 
			
		||||
CSRCS += stm32_extmem.c
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_SSD1289),y)
 | 
			
		||||
CSRCS += stm32_ssd1289.c
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_SSD1351),y)
 | 
			
		||||
CSRCS += stm32_ssd1351.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_UG2864AMBAG01),y)
 | 
			
		||||
CSRCS += stm32_ug2864ambag01.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_UG2864HSWEG01),y)
 | 
			
		||||
CSRCS += stm32_ug2864hsweg01.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_TESTING_OSTEST),y)
 | 
			
		||||
CSRCS += stm32_ostest.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_TIMER),y)
 | 
			
		||||
CSRCS += stm32_timer.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_STM32_HCIUART),y)
 | 
			
		||||
ifeq ($(CONFIG_BLUETOOTH_UART),y)
 | 
			
		||||
CSRCS += stm32_hciuart.c
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_STM32_ROMFS),y)
 | 
			
		||||
CSRCS += stm32_romfs_initialize.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y)
 | 
			
		||||
CSRCS += stm32_uid.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_USBMSC),y)
 | 
			
		||||
CSRCS += stm32_usbmsc.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifneq ($(CONFIG_STM32_ETHMAC),y)
 | 
			
		||||
ifeq ($(CONFIG_NETDEVICES),y)
 | 
			
		||||
CSRCS += stm32_netinit.c
 | 
			
		||||
endif
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_MMCSD_SPI),y)
 | 
			
		||||
CSRCS += stm32_mmcsd.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_WL_GS2200M),y)
 | 
			
		||||
CSRCS += stm32_gs2200m.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_LCD_ST7789),y)
 | 
			
		||||
CSRCS += stm32_st7789.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CONFIG_DEV_GPIO),y)
 | 
			
		||||
CSRCS += stm32_gpio.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
DEPPATH += --dep-path board
 | 
			
		||||
VPATH += :board
 | 
			
		||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
 | 
			
		||||
| 
						 | 
				
			
			@ -571,5 +571,14 @@ int stm32_bringup(void)
 | 
			
		|||
    }
 | 
			
		||||
#endif /* CONFIG_SENSORS_HS300X */
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_DEV_GPIO
 | 
			
		||||
  ret = stm32_gpio_initialize();
 | 
			
		||||
  if (ret < 0)
 | 
			
		||||
    {
 | 
			
		||||
      syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
 | 
			
		||||
      return ret;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,344 @@
 | 
			
		|||
/****************************************************************************
 | 
			
		||||
 * boards/arm/stm32/stm32f4discovery/src/stm32_goio.c
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed to the Apache Software Foundation (ASF) under one or more
 | 
			
		||||
 * contributor license agreements.  See the NOTICE file distributed with
 | 
			
		||||
 * this work for additional information regarding copyright ownership.  The
 | 
			
		||||
 * ASF licenses this file to you under the Apache License, Version 2.0 (the
 | 
			
		||||
 * "License"); you may not use this file except in compliance with the
 | 
			
		||||
 * License.  You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 | 
			
		||||
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 | 
			
		||||
 * License for the specific language governing permissions and limitations
 | 
			
		||||
 * under the License.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @file stm32_goio.c
 | 
			
		||||
* @brief nuttx source code
 | 
			
		||||
*                https://github.com/apache/incubator-nuttx.git
 | 
			
		||||
* @version 10.3.0 
 | 
			
		||||
* @author AIIT XUOS Lab
 | 
			
		||||
* @date 2022-05-19
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Included Files
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include <nuttx/config.h>
 | 
			
		||||
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <debug.h>
 | 
			
		||||
 | 
			
		||||
#include <nuttx/clock.h>
 | 
			
		||||
#include <nuttx/wdog.h>
 | 
			
		||||
#include <nuttx/ioexpander/gpio.h>
 | 
			
		||||
 | 
			
		||||
#include <arch/board/board.h>
 | 
			
		||||
 | 
			
		||||
#include "chip.h"
 | 
			
		||||
#include "stm32.h"
 | 
			
		||||
#include "stm32f4discovery.h"
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF)
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Private Types
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
struct stm32gpio_dev_s
 | 
			
		||||
{
 | 
			
		||||
  struct gpio_dev_s gpio;
 | 
			
		||||
  uint8_t id;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct stm32gpint_dev_s
 | 
			
		||||
{
 | 
			
		||||
  struct stm32gpio_dev_s stm32gpio;
 | 
			
		||||
  pin_interrupt_t callback;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Private Function Prototypes
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
#if BOARD_NGPIOIN > 0
 | 
			
		||||
static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOOUT > 0
 | 
			
		||||
static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value);
 | 
			
		||||
static int gpout_write(FAR struct gpio_dev_s *dev, bool value);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOINT > 0
 | 
			
		||||
static int stm32gpio_interrupt(int irq, void *context, void *arg);
 | 
			
		||||
static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value);
 | 
			
		||||
static int gpint_attach(FAR struct gpio_dev_s *dev,
 | 
			
		||||
                        pin_interrupt_t callback);
 | 
			
		||||
static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Private Data
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 #if BOARD_NGPIOIN > 0
 | 
			
		||||
static const struct gpio_operations_s gpin_ops =
 | 
			
		||||
{
 | 
			
		||||
  .go_read   = gpin_read,
 | 
			
		||||
  .go_write  = NULL,
 | 
			
		||||
  .go_attach = NULL,
 | 
			
		||||
  .go_enable = NULL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* This array maps the GPIO pins used as INPUT */
 | 
			
		||||
 | 
			
		||||
static const uint32_t g_gpioinputs[BOARD_NGPIOIN] =
 | 
			
		||||
{
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct stm32gpio_dev_s g_gpin[BOARD_NGPIOIN];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOOUT > 0
 | 
			
		||||
static const struct gpio_operations_s gpout_ops =
 | 
			
		||||
{
 | 
			
		||||
  .go_read   = gpout_read,
 | 
			
		||||
  .go_write  = gpout_write,
 | 
			
		||||
  .go_attach = NULL,
 | 
			
		||||
  .go_enable = NULL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* This array maps the GPIO pins used as OUTPUT */
 | 
			
		||||
 | 
			
		||||
static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] =
 | 
			
		||||
{
 | 
			
		||||
  GPIO_E22_M0,
 | 
			
		||||
  GPIO_E22_M1,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct stm32gpio_dev_s g_gpout[BOARD_NGPIOOUT];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOINT > 0
 | 
			
		||||
static const struct gpio_operations_s gpint_ops =
 | 
			
		||||
{
 | 
			
		||||
  .go_read   = gpint_read,
 | 
			
		||||
  .go_write  = NULL,
 | 
			
		||||
  .go_attach = gpint_attach,
 | 
			
		||||
  .go_enable = gpint_enable,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* This array maps the GPIO pins used as INTERRUPT INPUTS */
 | 
			
		||||
 | 
			
		||||
static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] =
 | 
			
		||||
{
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct stm32gpint_dev_s g_gpint[BOARD_NGPIOINT];
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Private Functions
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOIN > 0
 | 
			
		||||
static int gpin_read(FAR struct gpio_dev_s *dev, FAR bool *value)
 | 
			
		||||
{
 | 
			
		||||
  FAR struct stm32gpio_dev_s *stm32gpio =
 | 
			
		||||
                        (FAR struct stm32gpio_dev_s *)dev;
 | 
			
		||||
 | 
			
		||||
  DEBUGASSERT(stm32gpio != NULL && value != NULL);
 | 
			
		||||
  DEBUGASSERT(stm32gpio->id < BOARD_NGPIOIN);
 | 
			
		||||
  gpioinfo("Reading...\n");
 | 
			
		||||
 | 
			
		||||
  *value = stm32_gpioread(g_gpioinputs[stm32gpio->id]);
 | 
			
		||||
  return OK;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOOUT > 0
 | 
			
		||||
static int gpout_read(FAR struct gpio_dev_s *dev, FAR bool *value)
 | 
			
		||||
{
 | 
			
		||||
  FAR struct stm32gpio_dev_s *stm32gpio =
 | 
			
		||||
                        (FAR struct stm32gpio_dev_s *)dev;
 | 
			
		||||
 | 
			
		||||
  DEBUGASSERT(stm32gpio != NULL && value != NULL);
 | 
			
		||||
  DEBUGASSERT(stm32gpio->id < BOARD_NGPIOOUT);
 | 
			
		||||
  gpioinfo("Reading...\n");
 | 
			
		||||
 | 
			
		||||
  *value = stm32_gpioread(g_gpiooutputs[stm32gpio->id]);
 | 
			
		||||
  return OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int gpout_write(FAR struct gpio_dev_s *dev, bool value)
 | 
			
		||||
{
 | 
			
		||||
  FAR struct stm32gpio_dev_s *stm32gpio =
 | 
			
		||||
                             (FAR struct stm32gpio_dev_s *)dev;
 | 
			
		||||
 | 
			
		||||
  DEBUGASSERT(stm32gpio != NULL);
 | 
			
		||||
  DEBUGASSERT(stm32gpio->id < BOARD_NGPIOOUT);
 | 
			
		||||
  gpioinfo("Writing %d\n", (int)value);
 | 
			
		||||
 | 
			
		||||
  stm32_gpiowrite(g_gpiooutputs[stm32gpio->id], value);
 | 
			
		||||
  return OK;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOINT > 0
 | 
			
		||||
static int stm32gpio_interrupt(int irq, void *context, void *arg)
 | 
			
		||||
{
 | 
			
		||||
  FAR struct stm32gpint_dev_s *stm32gpint =
 | 
			
		||||
                        (FAR struct stm32gpint_dev_s *)arg;
 | 
			
		||||
 | 
			
		||||
  DEBUGASSERT(stm32gpint != NULL && stm32gpint->callback != NULL);
 | 
			
		||||
  gpioinfo("Interrupt! callback=%p\n", stm32gpint->callback);
 | 
			
		||||
 | 
			
		||||
  stm32gpint->callback(&stm32gpint->stm32gpio.gpio,
 | 
			
		||||
                       stm32gpint->stm32gpio.id);
 | 
			
		||||
  return OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int gpint_read(FAR struct gpio_dev_s *dev, FAR bool *value)
 | 
			
		||||
{
 | 
			
		||||
  FAR struct stm32gpint_dev_s *stm32gpint =
 | 
			
		||||
                              (FAR struct stm32gpint_dev_s *)dev;
 | 
			
		||||
 | 
			
		||||
  DEBUGASSERT(stm32gpint != NULL && value != NULL);
 | 
			
		||||
  DEBUGASSERT(stm32gpint->stm32gpio.id < BOARD_NGPIOINT);
 | 
			
		||||
  gpioinfo("Reading int pin...\n");
 | 
			
		||||
 | 
			
		||||
  *value = stm32_gpioread(g_gpiointinputs[stm32gpint->stm32gpio.id]);
 | 
			
		||||
  return OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int gpint_attach(FAR struct gpio_dev_s *dev,
 | 
			
		||||
                        pin_interrupt_t callback)
 | 
			
		||||
{
 | 
			
		||||
  FAR struct stm32gpint_dev_s *stm32gpint =
 | 
			
		||||
                             (FAR struct stm32gpint_dev_s *)dev;
 | 
			
		||||
 | 
			
		||||
  gpioinfo("Attaching the callback\n");
 | 
			
		||||
 | 
			
		||||
  /* Make sure the interrupt is disabled */
 | 
			
		||||
 | 
			
		||||
  stm32_gpiosetevent(g_gpiointinputs[stm32gpint->stm32gpio.id], false,
 | 
			
		||||
                     false, false, NULL, NULL);
 | 
			
		||||
 | 
			
		||||
  gpioinfo("Attach %p\n", callback);
 | 
			
		||||
  stm32gpint->callback = callback;
 | 
			
		||||
  return OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int gpint_enable(FAR struct gpio_dev_s *dev, bool enable)
 | 
			
		||||
{
 | 
			
		||||
  FAR struct stm32gpint_dev_s *stm32gpint =
 | 
			
		||||
                              (FAR struct stm32gpint_dev_s *)dev;
 | 
			
		||||
 | 
			
		||||
  if (enable)
 | 
			
		||||
    {
 | 
			
		||||
      if (stm32gpint->callback != NULL)
 | 
			
		||||
        {
 | 
			
		||||
          gpioinfo("Enabling the interrupt\n");
 | 
			
		||||
 | 
			
		||||
          /* Configure the interrupt for rising edge */
 | 
			
		||||
 | 
			
		||||
          stm32_gpiosetevent(g_gpiointinputs[stm32gpint->stm32gpio.id],
 | 
			
		||||
                             true, false, false, stm32gpio_interrupt,
 | 
			
		||||
                             &g_gpint[stm32gpint->stm32gpio.id]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      gpioinfo("Disable the interrupt\n");
 | 
			
		||||
      stm32_gpiosetevent(g_gpiointinputs[stm32gpint->stm32gpio.id],
 | 
			
		||||
                         false, false, false, NULL, NULL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return OK;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Public Functions
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_gpio_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize GPIO drivers for use with /apps/examples/gpio
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
int stm32_gpio_initialize(void)
 | 
			
		||||
{
 | 
			
		||||
  int i;
 | 
			
		||||
  int pincount;
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOIN > 0
 | 
			
		||||
  pincount = 0;
 | 
			
		||||
  for (i = 0; i < BOARD_NGPIOIN; i++)
 | 
			
		||||
    {
 | 
			
		||||
      /* Setup and register the GPIO pin */
 | 
			
		||||
 | 
			
		||||
      g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN;
 | 
			
		||||
      g_gpin[i].gpio.gp_ops     = &gpin_ops;
 | 
			
		||||
      g_gpin[i].id              = i;
 | 
			
		||||
      gpio_pin_register(&g_gpin[i].gpio, pincount);
 | 
			
		||||
 | 
			
		||||
      /* Configure the pin that will be used as input */
 | 
			
		||||
 | 
			
		||||
      stm32_configgpio(g_gpioinputs[i]);
 | 
			
		||||
 | 
			
		||||
      pincount++;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOOUT > 0
 | 
			
		||||
  pincount = 0;
 | 
			
		||||
  for (i = 0; i < BOARD_NGPIOOUT; i++)
 | 
			
		||||
    {
 | 
			
		||||
      /* Setup and register the GPIO pin */
 | 
			
		||||
 | 
			
		||||
      g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN;
 | 
			
		||||
      g_gpout[i].gpio.gp_ops     = &gpout_ops;
 | 
			
		||||
      g_gpout[i].id              = i;
 | 
			
		||||
      gpio_pin_register(&g_gpout[i].gpio, pincount);
 | 
			
		||||
 | 
			
		||||
      /* Configure the pin that will be used as output */
 | 
			
		||||
 | 
			
		||||
      stm32_gpiowrite(g_gpiooutputs[i], 0);
 | 
			
		||||
      stm32_configgpio(g_gpiooutputs[i]);
 | 
			
		||||
 | 
			
		||||
      pincount++;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if BOARD_NGPIOINT > 0
 | 
			
		||||
  pincount = 0;
 | 
			
		||||
  for (i = 0; i < BOARD_NGPIOINT; i++)
 | 
			
		||||
    {
 | 
			
		||||
      /* Setup and register the GPIO pin */
 | 
			
		||||
 | 
			
		||||
      g_gpint[i].stm32gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN;
 | 
			
		||||
      g_gpint[i].stm32gpio.gpio.gp_ops     = &gpint_ops;
 | 
			
		||||
      g_gpint[i].stm32gpio.id              = i;
 | 
			
		||||
      gpio_pin_register(&g_gpint[i].stm32gpio.gpio, pincount);
 | 
			
		||||
 | 
			
		||||
      /* Configure the pin that will be used as interrupt input */
 | 
			
		||||
 | 
			
		||||
      stm32_configgpio(g_gpiointinputs[i]);
 | 
			
		||||
 | 
			
		||||
      pincount++;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,885 @@
 | 
			
		|||
/****************************************************************************
 | 
			
		||||
 * boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed to the Apache Software Foundation (ASF) under one or more
 | 
			
		||||
 * contributor license agreements.  See the NOTICE file distributed with
 | 
			
		||||
 * this work for additional information regarding copyright ownership.  The
 | 
			
		||||
 * ASF licenses this file to you under the Apache License, Version 2.0 (the
 | 
			
		||||
 * "License"); you may not use this file except in compliance with the
 | 
			
		||||
 * License.  You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *   http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 | 
			
		||||
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 | 
			
		||||
 * License for the specific language governing permissions and limitations
 | 
			
		||||
 * under the License.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* @file stm32f4discovery.h
 | 
			
		||||
* @brief nuttx source code
 | 
			
		||||
*                https://github.com/apache/incubator-nuttx.git
 | 
			
		||||
* @version 10.3.0 
 | 
			
		||||
* @author AIIT XUOS Lab
 | 
			
		||||
* @date 2022-05-19
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef __BOARDS_ARM_STM32_STM32F4DISCOVERY_SRC_STM32F4DISCOVERY_H
 | 
			
		||||
#define __BOARDS_ARM_STM32_STM32F4DISCOVERY_SRC_STM32F4DISCOVERY_H
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Included Files
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include <nuttx/config.h>
 | 
			
		||||
#include <nuttx/compiler.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <arch/stm32/chip.h>
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Pre-processor Definitions
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
/* Configuration ************************************************************/
 | 
			
		||||
 | 
			
		||||
/* How many SPI modules does this chip support? */
 | 
			
		||||
 | 
			
		||||
#if STM32_NSPI < 1
 | 
			
		||||
#  undef CONFIG_STM32_SPI1
 | 
			
		||||
#  undef CONFIG_STM32_SPI2
 | 
			
		||||
#  undef CONFIG_STM32_SPI3
 | 
			
		||||
#elif STM32_NSPI < 2
 | 
			
		||||
#  undef CONFIG_STM32_SPI2
 | 
			
		||||
#  undef CONFIG_STM32_SPI3
 | 
			
		||||
#elif STM32_NSPI < 3
 | 
			
		||||
#  undef CONFIG_STM32_SPI3
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define PCA9635_I2CBUS  1
 | 
			
		||||
#define PCA9635_I2CADDR 0x40
 | 
			
		||||
 | 
			
		||||
/* Assume that we have everything */
 | 
			
		||||
 | 
			
		||||
#define HAVE_USBDEV     1
 | 
			
		||||
#define HAVE_USBHOST    1
 | 
			
		||||
#define HAVE_USBMONITOR 1
 | 
			
		||||
#define HAVE_SDIO       1
 | 
			
		||||
#define HAVE_CS43L22    1
 | 
			
		||||
#define HAVE_RTC_DRIVER 1
 | 
			
		||||
#define HAVE_NETMONITOR 1
 | 
			
		||||
#define HAVE_HCIUART    1
 | 
			
		||||
 | 
			
		||||
/* Can't support USB host or device features if USB OTG FS is not enabled */
 | 
			
		||||
 | 
			
		||||
#ifndef CONFIG_STM32_OTGFS
 | 
			
		||||
#  undef HAVE_USBDEV
 | 
			
		||||
#  undef HAVE_USBHOST
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Can't support USB device if USB device is not enabled */
 | 
			
		||||
 | 
			
		||||
#ifndef CONFIG_USBDEV
 | 
			
		||||
#  undef HAVE_USBDEV
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Can't support USB host is USB host is not enabled */
 | 
			
		||||
 | 
			
		||||
#ifndef CONFIG_USBHOST
 | 
			
		||||
#  undef HAVE_USBHOST
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Check if we should enable the USB monitor before starting NSH */
 | 
			
		||||
 | 
			
		||||
#ifndef CONFIG_USBMONITOR
 | 
			
		||||
#  undef HAVE_USBMONITOR
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef HAVE_USBDEV
 | 
			
		||||
#  undef CONFIG_USBDEV_TRACE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef HAVE_USBHOST
 | 
			
		||||
#  undef CONFIG_USBHOST_TRACE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !defined(CONFIG_USBDEV_TRACE) && !defined(CONFIG_USBHOST_TRACE)
 | 
			
		||||
#  undef HAVE_USBMONITOR
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Can't support MMC/SD features if mountpoints are disabled or if SDIO
 | 
			
		||||
 * support is not enabled.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_STM32_SDIO)
 | 
			
		||||
#  undef HAVE_SDIO
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#undef  SDIO_MINOR     /* Any minor number, default 0 */
 | 
			
		||||
#define SDIO_SLOTNO 0  /* Only one slot */
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_SDIO
 | 
			
		||||
#  if !defined(CONFIG_NSH_MMCSDSLOTNO)
 | 
			
		||||
#    define CONFIG_NSH_MMCSDSLOTNO SDIO_SLOTNO
 | 
			
		||||
#  elif CONFIG_NSH_MMCSDSLOTNO != 0
 | 
			
		||||
#    warning "Only one MMC/SD slot, slot 0"
 | 
			
		||||
#    undef CONFIG_NSH_MMCSDSLOTNO
 | 
			
		||||
#    define CONFIG_NSH_MMCSDSLOTNO SDIO_SLOTNO
 | 
			
		||||
#  endif
 | 
			
		||||
 | 
			
		||||
#  if defined(CONFIG_NSH_MMCSDMINOR)
 | 
			
		||||
#    define SDIO_MINOR CONFIG_NSH_MMCSDMINOR
 | 
			
		||||
#  else
 | 
			
		||||
#    define SDIO_MINOR 0
 | 
			
		||||
#  endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* The CS43L22 depends on the CS43L22 driver, I2C1, and I2S3 support */
 | 
			
		||||
 | 
			
		||||
#if !defined(CONFIG_AUDIO_CS43L22) || !defined(CONFIG_STM32_I2C1) || \
 | 
			
		||||
    !defined(CONFIG_STM32_I2S3)
 | 
			
		||||
#  undef HAVE_CS43L22
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_CS43L22
 | 
			
		||||
  /* The CS43L22 communicates on I2C1, I2C address 0x1a for control
 | 
			
		||||
   * operations
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
#  define CS43L22_I2C_BUS      1
 | 
			
		||||
#  define CS43L22_I2C_ADDRESS  (0x94 >> 1)
 | 
			
		||||
 | 
			
		||||
  /* The CS43L22 transfers data on I2S3 */
 | 
			
		||||
 | 
			
		||||
#  define CS43L22_I2S_BUS      3
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Check if we can support the RTC driver */
 | 
			
		||||
 | 
			
		||||
#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DRIVER)
 | 
			
		||||
#  undef HAVE_RTC_DRIVER
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* NSH Network monitor  */
 | 
			
		||||
 | 
			
		||||
#if !defined(CONFIG_NET) || !defined(CONFIG_STM32_EMACMAC)
 | 
			
		||||
#  undef HAVE_NETMONITOR
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !defined(CONFIG_NSH_NETINIT_THREAD) || !defined(CONFIG_ARCH_PHY_INTERRUPT) || \
 | 
			
		||||
    !defined(CONFIG_NETDEV_PHY_IOCTL) || !defined(CONFIG_NET_UDP)
 | 
			
		||||
#  undef HAVE_NETMONITOR
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* The NSH Network Monitor cannot be used with the STM32F4DIS-BB base board.
 | 
			
		||||
 * That is because the LAN8720 is configured in REF_CLK OUT mode.  In that
 | 
			
		||||
 * mode, the PHY interrupt is not supported.  The NINT pin serves instead as
 | 
			
		||||
 * REFLCK0.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_STM32F4DISBB
 | 
			
		||||
#  undef HAVE_NETMONITOR
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* procfs File System */
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_FS_PROCFS
 | 
			
		||||
#  ifdef CONFIG_NSH_PROC_MOUNTPOINT
 | 
			
		||||
#    define STM32_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
 | 
			
		||||
#  else
 | 
			
		||||
#    define STM32_PROCFS_MOUNTPOINT "/proc"
 | 
			
		||||
#  endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Check if we have the prerequisites for an HCI UART */
 | 
			
		||||
 | 
			
		||||
#if !defined(CONFIG_STM32_HCIUART) || !defined(CONFIG_BLUETOOTH_UART)
 | 
			
		||||
#  undef HAVE_HCIUART
 | 
			
		||||
#elif defined(CONFIG_STM32_USART1_HCIUART)
 | 
			
		||||
#  define HCIUART_SERDEV HCIUART1
 | 
			
		||||
#elif defined(CONFIG_STM32_USART2_HCIUART)
 | 
			
		||||
#  define HCIUART_SERDEV HCIUART2
 | 
			
		||||
#elif defined(CONFIG_STM32_USART3_HCIUART)
 | 
			
		||||
#  define HCIUART_SERDEV HCIUART3
 | 
			
		||||
#elif defined(CONFIG_STM32_USART6_HCIUART)
 | 
			
		||||
#  define HCIUART_SERDEV HCIUART6
 | 
			
		||||
#elif defined(CONFIG_STM32_UART7_HCIUART)
 | 
			
		||||
#  define HCIUART_SERDEV HCIUART7
 | 
			
		||||
#elif defined(CONFIG_STM32_UART8_HCIUART)
 | 
			
		||||
#  define HCIUART_SERDEV HCIUART8
 | 
			
		||||
#else
 | 
			
		||||
#  error No HCI UART specifified
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* STM32F4 Discovery GPIOs **************************************************/
 | 
			
		||||
 | 
			
		||||
/* LEDs */
 | 
			
		||||
 | 
			
		||||
#define GPIO_LED1       (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                         GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN12)
 | 
			
		||||
#define GPIO_LED2       (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                         GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN13)
 | 
			
		||||
#define GPIO_LED3       (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                         GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN14)
 | 
			
		||||
#define GPIO_LED4       (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                         GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN15)
 | 
			
		||||
 | 
			
		||||
/* BUTTONS -- NOTE that all have EXTI interrupts configured */
 | 
			
		||||
 | 
			
		||||
#define MIN_IRQBUTTON   BUTTON_USER
 | 
			
		||||
#define MAX_IRQBUTTON   BUTTON_USER
 | 
			
		||||
#define NUM_IRQBUTTONS  1
 | 
			
		||||
 | 
			
		||||
#define GPIO_BTN_USER   (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN0)
 | 
			
		||||
 | 
			
		||||
#define GPIO_CS43L22_RESET  (GPIO_OUTPUT|GPIO_SPEED_50MHz|GPIO_PORTD|GPIO_PIN4)
 | 
			
		||||
 | 
			
		||||
/* LoRa SX127x */
 | 
			
		||||
 | 
			
		||||
#define GPIO_SX127X_DIO0    (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTD|GPIO_PIN0)
 | 
			
		||||
 | 
			
		||||
#define GPIO_SX127X_RESET   (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_OUTPUT_CLEAR|\
 | 
			
		||||
                             GPIO_SPEED_50MHz|GPIO_PORTD|GPIO_PIN4)
 | 
			
		||||
 | 
			
		||||
/* PWM
 | 
			
		||||
 *
 | 
			
		||||
 * The STM32F4 Discovery has no real on-board PWM devices, but the board can
 | 
			
		||||
 * be configured to output a pulse train using TIM4 CH2 on PD13.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define STM32F4DISCOVERY_PWMTIMER   4
 | 
			
		||||
#define STM32F4DISCOVERY_PWMCHANNEL 2
 | 
			
		||||
 | 
			
		||||
/* SPI chip selects */
 | 
			
		||||
 | 
			
		||||
#define GPIO_CS_MEMS      (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3)
 | 
			
		||||
 | 
			
		||||
#define GPIO_MAX31855_CS  (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN8)
 | 
			
		||||
 | 
			
		||||
#define GPIO_MAX6675_CS   (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN8)
 | 
			
		||||
 | 
			
		||||
#define GPIO_SX127X_CS    (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN8)
 | 
			
		||||
 | 
			
		||||
#define GPIO_MAX7219_CS   (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN3)
 | 
			
		||||
 | 
			
		||||
#define GPIO_GS2200M_CS   (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN5)
 | 
			
		||||
 | 
			
		||||
#define GPIO_ENC28J60_CS    (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                             GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
 | 
			
		||||
 | 
			
		||||
#define GPIO_ENC28J60_RESET (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                             GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN1)
 | 
			
		||||
 | 
			
		||||
#define GPIO_ENC28J60_INTR  (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\
 | 
			
		||||
                             GPIO_OPENDRAIN|GPIO_PORTE|GPIO_PIN4)
 | 
			
		||||
 | 
			
		||||
/* USB OTG FS
 | 
			
		||||
 *
 | 
			
		||||
 * PA9  OTG_FS_VBUS VBUS sensing (also connected to the green LED)
 | 
			
		||||
 * PC0  OTG_FS_PowerSwitchOn
 | 
			
		||||
 * PD5  OTG_FS_Overcurrent
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define GPIO_OTGFS_VBUS   (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|\
 | 
			
		||||
                           GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN9)
 | 
			
		||||
#define GPIO_OTGFS_PWRON  (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|\
 | 
			
		||||
                           GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN0)
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_USBHOST
 | 
			
		||||
#  define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_EXTI|GPIO_FLOAT|\
 | 
			
		||||
                           GPIO_SPEED_100MHz|GPIO_PUSHPULL|\
 | 
			
		||||
                           GPIO_PORTD|GPIO_PIN5)
 | 
			
		||||
#else
 | 
			
		||||
#  define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|\
 | 
			
		||||
                           GPIO_PUSHPULL|GPIO_PORTD|GPIO_PIN5)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define BOARD_NGPIOIN   0 /* Amount of GPIO Input pins */
 | 
			
		||||
#define BOARD_NGPIOOUT  2 /* Amount of GPIO Output pins */
 | 
			
		||||
#define BOARD_NGPIOINT  0 /* Amount of GPIO Input w/ Interruption pins */
 | 
			
		||||
 | 
			
		||||
#define GPIO_E22_M0    (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                        GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN6)
 | 
			
		||||
 | 
			
		||||
#define GPIO_E22_M1    (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                        GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN7)
 | 
			
		||||
 | 
			
		||||
/* UG-2864AMBAG01 or UG-2864HSWEG01 OLED Display (SPI 4-wire):
 | 
			
		||||
 *
 | 
			
		||||
 * --------------------------+----------------------------------------------
 | 
			
		||||
 * Connector CON10 J1:      | STM32F4Discovery
 | 
			
		||||
 * --------------+-----------+----------------------------------------------
 | 
			
		||||
 * CON10 J1:     | CON20 J2: | P1/P2:
 | 
			
		||||
 * --------------+-----------+----------------------------------------------
 | 
			
		||||
 * 1  3v3        | 3,4 3v3   | P2 3V
 | 
			
		||||
 * 3  /RESET     | 8 /RESET  | P2 PB6 (Arbitrary selection)
 | 
			
		||||
 * 5  /CS        | 7 /CS     | P2 PB7 (Arbitrary selection)
 | 
			
		||||
 * 7  A0|D/C     | 9 A0|D/C  | P2 PB8 (Arbitrary selection)
 | 
			
		||||
 * 9  LED+ (N/C) | -----     | -----
 | 
			
		||||
 * 2  5V Vcc     | 1,2 Vcc   | P2 5V
 | 
			
		||||
 * 4  DI         | 18 D1/SI  | P1 PA7 (GPIO_SPI1_MOSI == GPIO_SPI1_MOSI_1(1))
 | 
			
		||||
 * 6  SCLK       | 19 D0/SCL | P1 PA5 (GPIO_SPI1_SCK == GPIO_SPI1_SCK_1(1))
 | 
			
		||||
 * 8  LED- (N/C) | -----     | ------
 | 
			
		||||
 * 10 GND        | 20 GND    | P2 GND
 | 
			
		||||
 * --------------+-----------+----------------------------------------------
 | 
			
		||||
 * (1) Required because of on-board MEMS
 | 
			
		||||
 * -------------------------------------------------------------------------
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_LCD_UG2864AMBAG01) || defined(CONFIG_LCD_UG2864HSWEG01) || \
 | 
			
		||||
    defined(CONFIG_LCD_SSD1351)
 | 
			
		||||
#  define GPIO_OLED_RESET (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN6)
 | 
			
		||||
#  define GPIO_OLED_CS    (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN7)
 | 
			
		||||
#  define GPIO_OLED_A0    (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN8)
 | 
			
		||||
#  define GPIO_OLED_DC    GPIO_OLED_A0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Display JLX12864G */
 | 
			
		||||
 | 
			
		||||
#define STM32_LCD_RST     (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN6)
 | 
			
		||||
 | 
			
		||||
#define STM32_LCD_CS      (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN7)
 | 
			
		||||
 | 
			
		||||
#define STM32_LCD_RS      (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN8)
 | 
			
		||||
 | 
			
		||||
/* STM32F4DIS-BB MicroSD
 | 
			
		||||
 *
 | 
			
		||||
 * ---------- ------------- ------------------------------
 | 
			
		||||
 * PIO        SIGNAL        Comments
 | 
			
		||||
 * ---------- ------------- ------------------------------
 | 
			
		||||
 * PB15       NCD           Pulled up externally
 | 
			
		||||
 * PC9        DAT1          Configured by driver
 | 
			
		||||
 * PC8        DAT0          "        " "" "    "
 | 
			
		||||
 * PC12       CLK           "        " "" "    "
 | 
			
		||||
 * PD2        CMD           "        " "" "    "
 | 
			
		||||
 * PC11       CD/DAT3       "        " "" "    "
 | 
			
		||||
 * PC10       DAT2          "        " "" "    "
 | 
			
		||||
 * ---------- ------------- ------------------------------
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_STM32F4DISBB) && defined(CONFIG_STM32_SDIO)
 | 
			
		||||
#  define GPIO_SDIO_NCD   (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\
 | 
			
		||||
                           GPIO_PORTB|GPIO_PIN15)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* STM32F4DIS-BB LAN8720
 | 
			
		||||
 *
 | 
			
		||||
 * ---------- ------------- ------------------------------
 | 
			
		||||
 * PIO        SIGNAL        Comments
 | 
			
		||||
 * ---------- ------------- ------------------------------
 | 
			
		||||
 * PB11       TXEN           Configured by driver
 | 
			
		||||
 * PB12       TXD0          "        " "" "    "
 | 
			
		||||
 * PB13       TXD1          "        " "" "    "
 | 
			
		||||
 * PC4        RXD0/MODE0    "        " "" "    "
 | 
			
		||||
 * PC5        RXD1/MODE1    "        " "" "    "
 | 
			
		||||
 * PA7        CRS_DIV/MODE2 "        " "" "    "
 | 
			
		||||
 * PA2        MDIO          "        " "" "    "
 | 
			
		||||
 * PC1        MDC           "        " "" "    "
 | 
			
		||||
 * PA1        NINT/REFCLK0  "        " "" "    "
 | 
			
		||||
 * PE2        DAT2          "        " "" "    "
 | 
			
		||||
 * ---------- ------------- ------------------------------
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_STM32F4DISBB) && defined(CONFIG_STM32_ETHMAC)
 | 
			
		||||
#  define GPIO_EMAC_NINT  (GPIO_INPUT|GPIO_PULLUP|GPIO_EXTI|\
 | 
			
		||||
                           GPIO_PORTA|GPIO_PIN1)
 | 
			
		||||
#  define GPIO_EMAC_NRST  (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
 | 
			
		||||
                           GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN2)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Public Types
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Public Data
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef __ASSEMBLY__
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Public Function Prototypes
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_bringup
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Perform architecture-specific initialization
 | 
			
		||||
 *
 | 
			
		||||
 *   CONFIG_BOARD_LATE_INITIALIZE=y :
 | 
			
		||||
 *     Called from board_late_initialize().
 | 
			
		||||
 *
 | 
			
		||||
 *   CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_BOARDCTL=y :
 | 
			
		||||
 *     Called from the NSH library
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
int stm32_bringup(void);
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_spidev_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Called to configure SPI chip select GPIO pins for the stm32f4discovery
 | 
			
		||||
 *   board.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
void weak_function stm32_spidev_initialize(void);
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_i2sdev_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Called to configure I2S chip select GPIO pins for the stm32f4discovery
 | 
			
		||||
 *   board.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
void weak_function stm32_i2sdev_initialize(void);
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_bh1750initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Called to configure an I2C and to register BH1750FVI for the
 | 
			
		||||
 *   stm32f4discovery board.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_SENSORS_BH1750FVI
 | 
			
		||||
int stm32_bh1750initialize(FAR const char *devpath);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_lpwaninitialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize SX127X LPWAN interaface.
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_LPWAN_SX127X
 | 
			
		||||
int stm32_lpwaninitialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_mmcsdinitialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Sets up MMC/SD interface.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_MMCSD_SPI
 | 
			
		||||
int stm32_mmcsd_initialize(int port, int minor);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: nunchuck_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize and register the button joystick driver
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_INPUT_NUNCHUCK
 | 
			
		||||
int nunchuck_initialize(FAR char *devname);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_max7219init
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize and register the max7219 numeric display controller
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_LEDS_MAX7219
 | 
			
		||||
int stm32_max7219init(FAR const char *devpath);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_ds1307_init
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize and register the DS1307 RTC
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_RTC_DS1307
 | 
			
		||||
int stm32_ds1307_init(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_st7032init
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize and register the Sitronix ST7032i
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
int stm32_st7032init(FAR const char *devpath);
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_usbinitialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Called from stm32_usbinitialize very early in initialization to setup
 | 
			
		||||
 *   USB-related GPIO pins for the STM32F4Discovery board.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_STM32_OTGFS
 | 
			
		||||
void weak_function stm32_usbinitialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_usbhost_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Called at application startup time to initialize the USB host
 | 
			
		||||
 *   functionality. This function will start a thread that will monitor for
 | 
			
		||||
 *   device connection/disconnection events.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST)
 | 
			
		||||
int stm32_usbhost_initialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_pwm_setup
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize PWM and register the PWM device.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_PWM
 | 
			
		||||
int stm32_pwm_setup(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_can_setup
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *  Initialize CAN and register the CAN device
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_STM32_CAN_CHARDRIVER
 | 
			
		||||
int stm32_can_setup(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_extmemgpios
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize GPIOs for external memory usage
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_STM32_FSMC
 | 
			
		||||
void stm32_extmemgpios(const uint32_t *gpios, int ngpios);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_extmemaddr
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize address line GPIOs for external memory access
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_STM32_FSMC
 | 
			
		||||
void stm32_extmemaddr(int naddrs);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_extmemdata
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize data line GPIOs for external memory access
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_STM32_FSMC
 | 
			
		||||
void stm32_extmemdata(int ndata);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_led_pminitialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Enable logic to use the LEDs on the STM32F4Discovery to support power
 | 
			
		||||
 *   management testing
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_PM
 | 
			
		||||
void stm32_led_pminitialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_pm_buttons
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Configure the user button of the STM32f4discovery board as EXTI,
 | 
			
		||||
 *   so it is able to wakeup the MCU from the PM_STANDBY mode
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#if defined(CONFIG_PM) && defined(CONFIG_ARCH_IDLE_CUSTOM) && \
 | 
			
		||||
    defined(CONFIG_PM_BUTTONS)
 | 
			
		||||
void stm32_pm_buttons(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_sdio_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize SDIO-based MMC/SD card support
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_STM32_SDIO)
 | 
			
		||||
int stm32_sdio_initialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_netinitialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Configure board resources to support networking.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_NETMONITOR
 | 
			
		||||
void weak_function stm32_netinitialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_zerocross_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize and register the zero cross driver
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_SENSORS_ZEROCROSS
 | 
			
		||||
int stm32_zerocross_initialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_max31855initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize and register the MAX31855 Temperature Sensor driver.
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   devpath - The full path to the driver to register. E.g., "/dev/temp0"
 | 
			
		||||
 *   bus     - Bus number (for hardware that has multiple SPI interfaces)
 | 
			
		||||
 *   devid   - ID associated to the device. E.g., 0, 1, 2, etc.
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero (OK) on success; a negated errno value on failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_SENSORS_MAX31855
 | 
			
		||||
int stm32_max31855initialize(FAR const char *devpath, int bus,
 | 
			
		||||
                             uint16_t devid);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_mlx90614init
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Called to configure an I2C and to register MLX90614 for the
 | 
			
		||||
 *   stm32f103-minimum board.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_SENSORS_MLX90614
 | 
			
		||||
int stm32_mlx90614init(FAR const char *devpath);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_max6675initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Initialize and register the max6675 driver
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_SENSORS_MAX6675
 | 
			
		||||
int stm32_max6675initialize(FAR const char *devpath);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_cs43l22_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   This function is called by platform-specific, setup logic to configure
 | 
			
		||||
 *   and register the CS43L22 device.  This function will register the
 | 
			
		||||
 *   driver as /dev/cs43l22[x] where x is determined by the minor device
 | 
			
		||||
 *   number.
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   minor - The input device minor number
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero is returned on success.  Otherwise, a negated errno value is
 | 
			
		||||
 *   returned to indicate the nature of the failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_CS43L22
 | 
			
		||||
int stm32_cs43l22_initialize(int minor);
 | 
			
		||||
#endif /* HAVE_CS43L22 */
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_pca9635_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   This function is called by board initialization logic to configure the
 | 
			
		||||
 *   LED PWM chip.  This function will register the driver as /dev/leddrv0.
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   None
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero is returned on success.  Otherwise, a negated errno value is
 | 
			
		||||
 *   returned to indicate the nature of the failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_PCA9635PW
 | 
			
		||||
int stm32_pca9635_initialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_rgbled_setup
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   This function is called by board initialization logic to configure the
 | 
			
		||||
 *   RGB LED driver.  This function will register the driver as /dev/rgbled0.
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   None
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero is returned on success.  Otherwise, a negated errno value is
 | 
			
		||||
 *   returned to indicate the nature of the failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_RGBLED
 | 
			
		||||
int stm32_rgbled_setup(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_timer_driver_setup
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Configure the timer driver.
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   devpath - The full path to the timer device.  This should be of the
 | 
			
		||||
 *             form /dev/timer0
 | 
			
		||||
 *   timer   - The timer's number.
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero (OK) is returned on success; A negated errno value is returned
 | 
			
		||||
 *   to indicate the nature of any failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_TIMER
 | 
			
		||||
int stm32_timer_driver_setup(FAR const char *devpath, int timer);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: xen1210_archinitialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Each board that supports an xen1210 device must provide this function.
 | 
			
		||||
 *   This function is called by application-specific, setup logic to
 | 
			
		||||
 *   configure the accelerometer device.  This function will register the
 | 
			
		||||
 *   driver as /dev/accelN where N is the minor device number.
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   minor   - The input device minor number
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero is returned on success.  Otherwise, a negated errno value is
 | 
			
		||||
 *   returned to indicate the nature of the failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_SENSORS_XEN1210
 | 
			
		||||
int xen1210_archinitialize(int minor);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: hciuart_dev_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   This function is called by board initialization logic to configure the
 | 
			
		||||
 *   Bluetooth HCI UART driver
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   None
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero is returned on success.  Otherwise, a negated errno value is
 | 
			
		||||
 *   returned to indicate the nature of the failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_HCIUART
 | 
			
		||||
int hciuart_dev_initialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/****************************************************************************
 | 
			
		||||
 * Name: stm32_gs2200m_initialize
 | 
			
		||||
 *
 | 
			
		||||
 * Description:
 | 
			
		||||
 *   Configure the gs2200m driver.
 | 
			
		||||
 *
 | 
			
		||||
 * Input Parameters:
 | 
			
		||||
 *   devpath - The full path to the device.
 | 
			
		||||
 *   bus     - The SPI bus number
 | 
			
		||||
 *
 | 
			
		||||
 * Returned Value:
 | 
			
		||||
 *   Zero (OK) is returned on success; A negated errno value is returned
 | 
			
		||||
 *   to indicate the nature of any failure.
 | 
			
		||||
 *
 | 
			
		||||
 ****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_WL_GS2200M
 | 
			
		||||
int stm32_gs2200m_initialize(FAR const char *devpath, int bus);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef CONFIG_DEV_GPIO
 | 
			
		||||
int stm32_gpio_initialize(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __ASSEMBLY__ */
 | 
			
		||||
#endif /* __BOARDS_ARM_STM32_STM32F4DISCOVERY_SRC_STM32F4DISCOVERY_H */
 | 
			
		||||
		Loading…
	
		Reference in New Issue