#include <start.h>

#include "inc/Android.h"
#include "inc/Flash.h"
#include "inc/UART.h"

#include <inc/communication_protocol.h>
#include <inc/thread.h>
#include "inc/uart_dev.h"
#include "inc/thread_communication.h"



/*
 * @brief   硬件初始化函数
 * @param
 * @retval
 *
 */
void hareware_init()
{
    android_PowerCtrl_Init();
    android_PowerKey_Init();

    android_PowerKey_Rest();
    rt_kprintf("\nandroid_PowerKey_Rest OK\n");


//    while (1) {
//
//    };
//    SPI_Flash_TEST();
}

/*
 * @brief   线程初始化函数
 * @param
 * @retval
 *
 */
void software_init()
{
    uart_all_dev_init();
    Send_mq_Init();
    Recv_thread_Init();
    Send_thread_Init();

    while (1) {
//        uart_dev_write(g_J4RS485_UART8_handle, "hello world\n", sizeof("hello world\n"));
        rt_thread_delay(1000);
    }
}

/*
 * @brief   启动函数
 * @param
 * @retval
 *
 */
void app_star()
{
//    hareware_init();
//    software_init();

    android_PowerCtrl_Init();
    android_PowerKey_Init();
    android_PowerKey_Rest();
    rt_kprintf("\nandroid_PowerKey_Rest OK\n");

    uart_all_dev_init();
    Send_mq_Init();
    Recv_thread_Init();
    Send_thread_Init();

    J1_485_Init(9600);
    J1_PWR_Open();
    rt_thread_mdelay(5000);

    J2_485_Init(9600);
    J2_PWR_Open();
    rt_thread_mdelay(5000);

    J3_485_Init(9600);
    J3_PWR_Open();
    rt_thread_mdelay(5000);

    J4_485_Init(9600);
    J4_PWR_Open();
    rt_thread_mdelay(5000);


    J5_0_485_Init(9600);
    J5_PWR_Open();
    rt_thread_mdelay(5000);

    J6_PWR_Open();
    rt_thread_mdelay(5000);

    J7_PWR_Open();
    rt_thread_mdelay(5000);

    J8_PWR_Open();
    rt_thread_mdelay(5000);

    J9_PWR_Open();
    rt_thread_mdelay(5000);

    while (1) {
//        uart_dev_write(g_J4RS485_UART8_handle, "hello world\n", sizeof("hello world\n"));
        rt_thread_delay(1000);
    }
}



