27 lines
798 B
C
27 lines
798 B
C
#include "util.h"
|
|
#include "main.h"
|
|
#include "stm32f3xx_hal_gpio.h"
|
|
|
|
void set_error_led() {
|
|
HAL_GPIO_WritePin(STATUS2_GPIO_Port, STATUS2_Pin, GPIO_PIN_SET);
|
|
}
|
|
|
|
uint64_t ntohll(uint64_t netlonglong) {
|
|
uint8_t *p = (uint8_t *)&netlonglong;
|
|
return ((uint64_t)p[0] << 56) | ((uint64_t)p[1] << 48) |
|
|
((uint64_t)p[2] << 40) | ((uint64_t)p[3] << 32) |
|
|
((uint64_t)p[4] << 24) | ((uint64_t)p[5] << 16) |
|
|
((uint64_t)p[6] << 8) | ((uint64_t)p[7] << 0);
|
|
}
|
|
|
|
uint32_t ntohl(uint32_t netlong) {
|
|
uint8_t *p = (uint8_t *)&netlong;
|
|
return ((uint32_t)p[3] << 24) | ((uint32_t)p[2] << 16) |
|
|
((uint32_t)p[1] << 8) | ((uint32_t)p[0] << 0);
|
|
}
|
|
|
|
uint16_t ntohs(uint16_t netshort) {
|
|
uint8_t *p = (uint8_t *)&netshort;
|
|
return ((uint16_t)p[1] << 8) | ((uint16_t)p[0] << 0);
|
|
}
|