diff --git a/mongoose.c b/mongoose.c index 62fde56a..8bb6ec21 100644 --- a/mongoose.c +++ b/mongoose.c @@ -664,7 +664,7 @@ MG_IRAM bool mg_flash_erase(void *addr) { return ok; } -MG_IRAM bool mg_flash_swap_bank() { +MG_IRAM bool mg_flash_swap_bank(void) { return true; } @@ -1007,7 +1007,7 @@ MG_IRAM bool mg_flash_erase(void *addr) { return ok; } -MG_IRAM bool mg_flash_swap_bank() { +MG_IRAM bool mg_flash_swap_bank(void) { if (mg_flash_bank() == 0) return true; uint32_t bank = FLASH_BASE1; uint32_t desired = flash_bank_is_swapped(bank) ? 0 : MG_BIT(31); diff --git a/mongoose.h b/mongoose.h index 9ae50713..b6a408a6 100644 --- a/mongoose.h +++ b/mongoose.h @@ -1055,9 +1055,9 @@ uint64_t mg_now(void); // Return milliseconds since Epoch #define mg_htons(x) mg_ntohs(x) #define mg_htonl(x) mg_ntohl(x) -#define MG_U32(a, b, c, d) \ - (((uint32_t) ((a) &255) << 24) | ((uint32_t) ((b) &255) << 16) | \ - ((uint32_t) ((c) &255) << 8) | (uint32_t) ((d) &255)) +#define MG_U32(a, b, c, d) \ + (((uint32_t) ((a) & 255) << 24) | ((uint32_t) ((b) & 255) << 16) | \ + ((uint32_t) ((c) & 255) << 8) | (uint32_t) ((d) & 255)) // For printing IPv4 addresses: printf("%d.%d.%d.%d\n", MG_IPADDR_PARTS(&ip)) #define MG_U8P(ADDR) ((uint8_t *) (ADDR)) @@ -1071,9 +1071,12 @@ uint64_t mg_now(void); // Return milliseconds since Epoch #define MG_ROUND_UP(x, a) ((a) == 0 ? (x) : ((((x) + (a) -1) / (a)) * (a))) #define MG_ROUND_DOWN(x, a) ((a) == 0 ? (x) : (((x) / (a)) * (a))) -#ifdef __GNUC__ +#if defined(__GNUC__) #define MG_ARM_DISABLE_IRQ() asm volatile("cpsid i" : : : "memory") #define MG_ARM_ENABLE_IRQ() asm volatile("cpsie i" : : : "memory") +#elif defined(__CCRH__) +#define MG_RH850_DISABLE_IRQ() __DI() +#define MG_RH850_ENABLE_IRQ() __EI() #else #define MG_ARM_DISABLE_IRQ() #define MG_ARM_ENABLE_IRQ() @@ -2676,6 +2679,7 @@ MG_IRAM void mg_ota_boot(void); // Bootloader function #define MG_DEVICE_RT1020 3 // IMXRT1020 #define MG_DEVICE_RT1060 4 // IMXRT1060 #define MG_DEVICE_CH32V307 100 // WCH CH32V307 +#define MG_DEVICE_U2A 200 // Renesas U2A16, U2A8, U2A6 #define MG_DEVICE_CUSTOM 1000 // Custom implementation #ifndef MG_DEVICE diff --git a/src/device.h b/src/device.h index c4a7ee88..d90b82da 100644 --- a/src/device.h +++ b/src/device.h @@ -11,6 +11,7 @@ #define MG_DEVICE_RT1020 3 // IMXRT1020 #define MG_DEVICE_RT1060 4 // IMXRT1060 #define MG_DEVICE_CH32V307 100 // WCH CH32V307 +#define MG_DEVICE_U2A 200 // Renesas U2A16, U2A8, U2A6 #define MG_DEVICE_CUSTOM 1000 // Custom implementation #ifndef MG_DEVICE diff --git a/src/device_imxrt.c b/src/device_imxrt.c index f1b2b9e2..9571b136 100644 --- a/src/device_imxrt.c +++ b/src/device_imxrt.c @@ -249,7 +249,7 @@ MG_IRAM bool mg_flash_erase(void *addr) { return ok; } -MG_IRAM bool mg_flash_swap_bank() { +MG_IRAM bool mg_flash_swap_bank(void) { return true; } diff --git a/src/device_stm32h7.c b/src/device_stm32h7.c index fe40232a..e3f7c777 100644 --- a/src/device_stm32h7.c +++ b/src/device_stm32h7.c @@ -104,7 +104,7 @@ MG_IRAM bool mg_flash_erase(void *addr) { return ok; } -MG_IRAM bool mg_flash_swap_bank() { +MG_IRAM bool mg_flash_swap_bank(void) { if (mg_flash_bank() == 0) return true; uint32_t bank = FLASH_BASE1; uint32_t desired = flash_bank_is_swapped(bank) ? 0 : MG_BIT(31); diff --git a/src/util.h b/src/util.h index 0b2bb49a..7f2ba359 100644 --- a/src/util.h +++ b/src/util.h @@ -23,9 +23,9 @@ uint64_t mg_now(void); // Return milliseconds since Epoch #define mg_htons(x) mg_ntohs(x) #define mg_htonl(x) mg_ntohl(x) -#define MG_U32(a, b, c, d) \ - (((uint32_t) ((a) &255) << 24) | ((uint32_t) ((b) &255) << 16) | \ - ((uint32_t) ((c) &255) << 8) | (uint32_t) ((d) &255)) +#define MG_U32(a, b, c, d) \ + (((uint32_t) ((a) & 255) << 24) | ((uint32_t) ((b) & 255) << 16) | \ + ((uint32_t) ((c) & 255) << 8) | (uint32_t) ((d) & 255)) // For printing IPv4 addresses: printf("%d.%d.%d.%d\n", MG_IPADDR_PARTS(&ip)) #define MG_U8P(ADDR) ((uint8_t *) (ADDR)) @@ -39,9 +39,12 @@ uint64_t mg_now(void); // Return milliseconds since Epoch #define MG_ROUND_UP(x, a) ((a) == 0 ? (x) : ((((x) + (a) -1) / (a)) * (a))) #define MG_ROUND_DOWN(x, a) ((a) == 0 ? (x) : (((x) / (a)) * (a))) -#ifdef __GNUC__ +#if defined(__GNUC__) #define MG_ARM_DISABLE_IRQ() asm volatile("cpsid i" : : : "memory") #define MG_ARM_ENABLE_IRQ() asm volatile("cpsie i" : : : "memory") +#elif defined(__CCRH__) +#define MG_RH850_DISABLE_IRQ() __DI() +#define MG_RH850_ENABLE_IRQ() __EI() #else #define MG_ARM_DISABLE_IRQ() #define MG_ARM_ENABLE_IRQ()