#ifdef STM32F767xx
#include "stm32f7xx_hal.h"
-#include "gpio.h"
#include "usart.h"
+#include "gpio.h"
+
+#define SET_LED_RED GPIOB->BSRR = GPIO_PIN_14
+#define RESET_LED_RED GPIOB->BSRR = GPIO_PIN_14 << 16
+
+#define SET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7
+#define RESET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7 << 16
+
+#define SET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0
+#define RESET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0 << 16
+
#else
#include <stdio.h>
#include <netdb.h>
#include "interface.h"
-#define SET_LED_RED GPIOB->BSRR = GPIO_PIN_14
-#define RESET_LED_RED GPIOB->BSRR = GPIO_PIN_14 << 16
-
-#define SET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7
-#define RESET_LED_BLUE GPIOB->BSRR = GPIO_PIN_7 << 16
-
-#define SET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0
-#define RESET_LED_GREEN GPIOB->BSRR = GPIO_PIN_0 << 16
-
//Globals
#ifdef STM32F767xx
volatile char uartf = 0;
bool input_available(){
#ifdef STM32F767xx
+ if(HAL_UART_Receive(&huart3, &bt, 1, 1) == HAL_TIMEOUT)
+ return false;
return true;
#else
struct timeval tv;
FD_SET(fd, &fds);
if (select(fd+1, &fds, NULL, NULL, &tv) == -1)
pdie("select");
- return FD_ISSET(fd, &fds);
+ if(!FD_ISSET(fd, &fds))
+ return false;
+ read(fd, &bt, 1);
+ return true;
#endif
}
{
#ifdef STM32F767xx
HAL_UART_Receive(&huart3, &bt, 1, 1000);
- return 0;
+ return bt;
#else
read(fd, &bt, 1);
return bt;
{
#ifdef STM32F767xx
#else
- debug("dwrite %d: %d\n", i, b);
+ debug("dwrite %d: %d", i, b);
#endif
+ (void) i;
+ (void) b;
}
bool read_dpin(uint8_t i)
#ifdef STM32F767xx
return false;
#else
- debug("dread %d\n", i);
+ debug("dread %d", i);
return false;
#endif
+ (void) i;
}
void write_apin(uint8_t i, uint8_t a)
SET_LED_GREEN;
}
#else
- debug("awrite %d: %d\n", i, a);
+ debug("awrite %d: %d", i, a);
#endif
+ (void) a;
+ (void) i;
}
uint8_t read_apin(uint8_t i)
#ifdef STM32F767xx
return 0;
#else
- debug("aread %d\n", i);
+ debug("aread %d", i);
return 0;
#endif
+ (void) i;
}
void delay(long ms)
int port = 8123, opti = 1;
//Register signal handler
if(signal(SIGINT, killHandler) == SIG_ERR){
- die("Couldn't register signal handler...\n");
+ die("Couldn't register signal handler...");
}
if(signal(SIGTERM, killHandler) == SIG_ERR){
- die("Couldn't register signal handler...\n");
+ die("Couldn't register signal handler...");
}
//Command line arguments
while(opti < gargc){
} else if(strcmp(gargv[opti], "-p") == 0 && opti+1<gargc){
port = atoi(gargv[++opti]);
if(port < 1)
- die("Port numbers are > 1\n");
+ die("Port numbers are > 1");
} else {
usage(stderr, gargv[0]);
exit(EXIT_FAILURE);