xiuos/APP_Framework/Applications/main.c

97 lines
2.3 KiB
C

/*
* 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.
*/
#include <stdio.h>
#include <string.h>
// #include <user_api.h>
#include <transform.h>
extern int FrameworkInit();
extern void ApplicationOtaTaskInit(void);
#ifdef OTA_BY_PLATFORM
extern int OtaTask(void);
#endif
#ifdef APPLICATION_WEBSERVER
extern int webserver(void);
#endif
int main(void)
{
printf("\nHello, world!\n");
FrameworkInit();
#ifdef APPLICATION_OTA
ApplicationOtaTaskInit();
#endif
#ifdef OTA_BY_PLATFORM
OtaTask();
#endif
#ifdef APPLICATION_WEBSERVER
webserver();
#endif
int pin_fd = PrivOpen("/dev/pin_dev", O_RDWR);
if(pin_fd < 0) {
printf("open pin fd error:%d\n",pin_fd);
return pin_fd;
}
//config led pin in board
struct PinStat pin_led;
pin_led.pin = 57;
// pin_led.pin = 8;
struct PinParam parameter;
parameter.cmd = GPIO_CONFIG_MODE;
parameter.pin = pin_led.pin;
parameter.mode = GPIO_CFG_OUTPUT;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = (void *)&parameter;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return pin_fd;
}
PrivTaskDelay(20);
int counter = 0;
while(1){
printf("counter:%d\n",counter++);
pin_led.val = GPIO_HIGH;
if(0 > PrivWrite(pin_fd, &pin_led, NULL_PARAMETER)) {
printf("write pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return pin_fd;
}
PrivTaskDelay(20);
pin_led.val = GPIO_LOW;
if(0 > PrivWrite(pin_fd, &pin_led, NULL_PARAMETER)) {
printf("write pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return pin_fd;
}
PrivTaskDelay(4980);
}
return 0;
}
// int cppmain(void);