fix compiler warnings
This commit is contained in:
@@ -81,7 +81,7 @@ void I2C_Init(I2C_ModeTypeDef I2C_Mode, UINT32 I2C_ClockSpeed, I2C_DutyTypeDef I
|
|||||||
R16_I2C_CTRL1 &= ~(RB_I2C_SMBUS | RB_I2C_SMBTYPE | RB_I2C_ACK);
|
R16_I2C_CTRL1 &= ~(RB_I2C_SMBUS | RB_I2C_SMBTYPE | RB_I2C_ACK);
|
||||||
R16_I2C_CTRL1 |= I2C_Mode | I2C_Ack;
|
R16_I2C_CTRL1 |= I2C_Mode | I2C_Ack;
|
||||||
|
|
||||||
R16_I2C_OADDR1 &= ~0xFFFF;
|
R16_I2C_OADDR1 &= ~0xFFFFU;
|
||||||
R16_I2C_OADDR1 |= I2C_AckAddr | I2C_OwnAddress1;
|
R16_I2C_OADDR1 |= I2C_AckAddr | I2C_OwnAddress1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
Makefile
7
Makefile
@@ -56,7 +56,6 @@ CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_usb2dev.c \
|
|||||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_spi1.c \
|
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_spi1.c \
|
||||||
CH5xx_ble_firmware_library/RVMSIS/core_riscv.c \
|
CH5xx_ble_firmware_library/RVMSIS/core_riscv.c \
|
||||||
src/main.c \
|
src/main.c \
|
||||||
src/debug.c \
|
|
||||||
src/leddrv.c \
|
src/leddrv.c \
|
||||||
src/button.c \
|
src/button.c \
|
||||||
src/bmlist.c \
|
src/bmlist.c \
|
||||||
@@ -74,7 +73,6 @@ src/data.c \
|
|||||||
src/usb/utils.c \
|
src/usb/utils.c \
|
||||||
src/usb/setup.c \
|
src/usb/setup.c \
|
||||||
src/usb/ctrl.c \
|
src/usb/ctrl.c \
|
||||||
src/usb/debug.c \
|
|
||||||
src/usb/dev.c \
|
src/usb/dev.c \
|
||||||
src/usb/composite/hiddev.c \
|
src/usb/composite/hiddev.c \
|
||||||
src/usb/composite/cdc-serial.c \
|
src/usb/composite/cdc-serial.c \
|
||||||
@@ -84,6 +82,11 @@ src/animation.c \
|
|||||||
src/font.c \
|
src/font.c \
|
||||||
src/power.c \
|
src/power.c \
|
||||||
|
|
||||||
|
ifdef DEBUG
|
||||||
|
C_SOURCES += \
|
||||||
|
src/debug.c \
|
||||||
|
src/usb/debug.c
|
||||||
|
endif
|
||||||
|
|
||||||
# ASM sources
|
# ASM sources
|
||||||
ASM_SOURCES = \
|
ASM_SOURCES = \
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t *bytes;
|
const uint8_t *bytes;
|
||||||
int size;
|
int size;
|
||||||
} byte_t;
|
} byte_t;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "bmlist.h"
|
#include "bmlist.h"
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
volatile static bm_t *current, *head, *tail;
|
static bm_t *current, *head, *tail;
|
||||||
|
|
||||||
static void bm_add(bm_t *new, bm_t *prev, bm_t *next)
|
static void bm_add(bm_t *new, bm_t *prev, bm_t *next)
|
||||||
{
|
{
|
||||||
@@ -63,13 +63,14 @@ static void list_del(bm_t *prev, bm_t *next)
|
|||||||
|
|
||||||
bm_t *bmlist_drop(bm_t *bm)
|
bm_t *bmlist_drop(bm_t *bm)
|
||||||
{
|
{
|
||||||
|
bm_t *next = bm->next;
|
||||||
list_del(bm->prev, bm->next);
|
list_del(bm->prev, bm->next);
|
||||||
if (bm == head)
|
if (bm == head)
|
||||||
head = bm->next;
|
head = bm->next;
|
||||||
if (bm == tail)
|
if (bm == tail)
|
||||||
tail = bm->prev;
|
tail = bm->prev;
|
||||||
free(bm);
|
free(bm);
|
||||||
return bm->next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
bm_t *bm_new(uint16_t width)
|
bm_t *bm_new(uint16_t width)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "res/foss-asia-2.xbm"
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "util/crc.h"
|
#include "util/crc.h"
|
||||||
|
|
||||||
|
|||||||
11
src/data.c
11
src/data.c
@@ -7,11 +7,16 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "leddrv.h"
|
#include "leddrv.h"
|
||||||
|
|
||||||
uint32_t bigendian16_sum(uint16_t *s, int len)
|
uint32_t bigendian16_sum(const uint8_t *s, int len)
|
||||||
{
|
{
|
||||||
uint32_t sum = 0;
|
uint32_t sum = 0;
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
sum += bswap16(s[len]);
|
// Read the big-endian bytes for this uint16_t
|
||||||
|
uint8_t high = s[len * 2]; // MSB (most significant byte)
|
||||||
|
uint8_t low = s[len * 2 + 1]; // LSB (least significant byte)
|
||||||
|
// Reconstruct the uint16_t value (big-endian to little-endian equivalent)
|
||||||
|
uint16_t val = (high << 8) | low;
|
||||||
|
sum += val;
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@@ -42,7 +47,7 @@ uint16_t data_flash2newmem(uint8_t **chunk, uint32_t n)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
uint16_t offs = LEGACY_HEADER_SIZE
|
uint16_t offs = LEGACY_HEADER_SIZE
|
||||||
+ bigendian16_sum(header.sizes, n) * LED_ROWS;
|
+ bigendian16_sum((const uint8_t*)header.sizes, n) * LED_ROWS;
|
||||||
|
|
||||||
*chunk = malloc(size);
|
*chunk = malloc(size);
|
||||||
EEPROM_READ(offs, *chunk, size);
|
EEPROM_READ(offs, *chunk, size);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ enum ANIMATION_MODES {
|
|||||||
static inline uint16_t bswap16(uint16_t i) {
|
static inline uint16_t bswap16(uint16_t i) {
|
||||||
return (i >> 8) | (i << 8);
|
return (i >> 8) | (i << 8);
|
||||||
}
|
}
|
||||||
uint32_t bigendian16_sum(uint16_t *s, int len);
|
uint32_t bigendian16_sum(const uint8_t *s, int len);
|
||||||
|
|
||||||
uint32_t data_flatSave(uint8_t *data, uint32_t len);
|
uint32_t data_flatSave(uint8_t *data, uint32_t len);
|
||||||
uint16_t data_flash2newmem(uint8_t **chunk, uint32_t n);
|
uint16_t data_flash2newmem(uint8_t **chunk, uint32_t n);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ int legacy_ble_rx(uint8_t *val, uint16_t len)
|
|||||||
|
|
||||||
if (c == 1) {
|
if (c == 1) {
|
||||||
data_legacy_t *d = (data_legacy_t *)data;
|
data_legacy_t *d = (data_legacy_t *)data;
|
||||||
n = bigendian16_sum(d->sizes, 8);
|
n = bigendian16_sum((uint8_t*)d->sizes, 8);
|
||||||
data_len = LEGACY_HEADER_SIZE + LED_ROWS * n;
|
data_len = LEGACY_HEADER_SIZE + LED_ROWS * n;
|
||||||
PRINT("Data len: %d\n", data_len);
|
PRINT("Data len: %d\n", data_len);
|
||||||
data = realloc(data, data_len);
|
data = realloc(data, data_len);
|
||||||
@@ -96,7 +96,7 @@ int legacy_usb_rx(uint8_t *buf, uint16_t len)
|
|||||||
|
|
||||||
if (!data_len) {
|
if (!data_len) {
|
||||||
data_legacy_t *d = (data_legacy_t *)data;
|
data_legacy_t *d = (data_legacy_t *)data;
|
||||||
uint16_t n = bigendian16_sum(d->sizes, 8);
|
uint16_t n = bigendian16_sum((uint8_t*)d->sizes, 8);
|
||||||
data_len = LEGACY_HEADER_SIZE + LED_ROWS * n;
|
data_len = LEGACY_HEADER_SIZE + LED_ROWS * n;
|
||||||
data = realloc(data, data_len);
|
data = realloc(data, data_len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ enum MODES {
|
|||||||
|
|
||||||
static tmosTaskID common_taskid = INVALID_TASK_ID ;
|
static tmosTaskID common_taskid = INVALID_TASK_ID ;
|
||||||
|
|
||||||
volatile uint16_t fb[LED_COLS] = {0};
|
uint16_t fb[LED_COLS] = {0};
|
||||||
volatile int mode, is_play_sequentially = 1;
|
volatile int mode, is_play_sequentially = 1;
|
||||||
|
|
||||||
__HIGH_CODE
|
__HIGH_CODE
|
||||||
@@ -435,7 +435,7 @@ int main()
|
|||||||
disp_charging();
|
disp_charging();
|
||||||
cfg_init();
|
cfg_init();
|
||||||
xbm_t spl = {
|
xbm_t spl = {
|
||||||
.bits = &(badge_cfg.splash_bm_bits),
|
.bits = badge_cfg.splash_bm_bits,
|
||||||
.w = badge_cfg.splash_bm_w,
|
.w = badge_cfg.splash_bm_w,
|
||||||
.h = badge_cfg.splash_bm_h,
|
.h = badge_cfg.splash_bm_h,
|
||||||
.fh = badge_cfg.splash_bm_fh,
|
.fh = badge_cfg.splash_bm_fh,
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ uint8_t load_fallback_cfg(uint8_t *val, uint16_t len)
|
|||||||
{
|
{
|
||||||
PRINT(__func__);
|
PRINT(__func__);
|
||||||
PRINT("\n");
|
PRINT("\n");
|
||||||
cfg_fallback(&badge_cfg);
|
cfg_fallback();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ void power_init()
|
|||||||
GPIOA_ModeCfg(GPIO_Pin_5, GPIO_ModeIN_Floating);
|
GPIOA_ModeCfg(GPIO_Pin_5, GPIO_ModeIN_Floating);
|
||||||
ADC_ExtSingleChSampInit(SampleFreq_3_2, ADC_PGA_0);
|
ADC_ExtSingleChSampInit(SampleFreq_3_2, ADC_PGA_0);
|
||||||
|
|
||||||
int16_t adc_calib = ADC_DataCalib_Rough();
|
PRINT("RoughCalib_Value = %d \n", ADC_DataCalib_Rough());
|
||||||
PRINT("RoughCalib_Value = %d \n", adc_calib);
|
|
||||||
|
|
||||||
ADC_ChannelCfg(1);
|
ADC_ChannelCfg(1);
|
||||||
}
|
}
|
||||||
@@ -38,7 +37,6 @@ int batt_raw()
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
PRINT("ADC reading: \n");
|
PRINT("ADC reading: \n");
|
||||||
uint16_t buf[20];
|
|
||||||
for(int i = 0; i < 20; i++) {
|
for(int i = 0; i < 20; i++) {
|
||||||
uint16_t adc = ADC_ExcutSingleConver();
|
uint16_t adc = ADC_ExcutSingleConver();
|
||||||
ret += adc;
|
ret += adc;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#define foss_asia_2_width 44
|
#define foss_asia_2_width 44
|
||||||
#define foss_asia_2_height 22
|
#define foss_asia_2_height 22
|
||||||
static unsigned char foss_asia_2_bits[] = {
|
unsigned const char foss_asia_2_bits[] = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xf9, 0x8f, 0xff, 0xfc, 0x07,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xf9, 0x8f, 0xff, 0xfc, 0x07,
|
||||||
0xfe, 0xfd, 0xdf, 0xff, 0xfe, 0x07, 0x06, 0x0c, 0xd8, 0x00, 0x06, 0x00,
|
0xfe, 0xfd, 0xdf, 0xff, 0xfe, 0x07, 0x06, 0x0c, 0xd8, 0x00, 0x06, 0x00,
|
||||||
0xff, 0x0d, 0xd8, 0x7f, 0xfe, 0x03, 0xff, 0x0d, 0x98, 0xff, 0xfc, 0x07,
|
0xff, 0x0d, 0xd8, 0x7f, 0xfe, 0x03, 0xff, 0x0d, 0x98, 0xff, 0xfc, 0x07,
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
#define USB_DESCTYPE_CS_INTERFACE 0x24
|
#define USB_DESCTYPE_CS_INTERFACE 0x24
|
||||||
|
|
||||||
static __attribute__((aligned(4))) uint8_t noti_ep_buf[64 + 64];
|
static __attribute__((aligned(4))) uint8_t noti_ep_buf[64 + 64];
|
||||||
static uint8_t *const noti_ep_out = noti_ep_buf;
|
|
||||||
static uint8_t *const noti_ep_in = noti_ep_buf + 64;
|
|
||||||
|
|
||||||
static __attribute__((aligned(4))) uint8_t data_ep_buf[64 + 64];
|
static __attribute__((aligned(4))) uint8_t data_ep_buf[64 + 64];
|
||||||
static uint8_t *const data_ep_out = data_ep_buf;
|
static uint8_t *const data_ep_out = data_ep_buf;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void usb_set_address(uint8_t ad)
|
|||||||
address = ad;
|
address = ad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ctrl_start_load_block(void *buf, uint16_t len)
|
void ctrl_start_load_block(const void *buf, uint16_t len)
|
||||||
{
|
{
|
||||||
usb_start_load_block(ep0buf, buf, len, 1);
|
usb_start_load_block(ep0buf, buf, len, 1);
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,9 @@ static void ep_handler()
|
|||||||
switch(token) {
|
switch(token) {
|
||||||
|
|
||||||
case UIS_TOKEN_SETUP:
|
case UIS_TOKEN_SETUP:
|
||||||
print_setuppk(req);
|
#ifdef DEBUG
|
||||||
|
print_setuppk(request);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (recip == USB_REQ_RECIP_DEVICE) {
|
if (recip == USB_REQ_RECIP_DEVICE) {
|
||||||
handle_devreq(request);
|
handle_devreq(request);
|
||||||
@@ -128,12 +130,16 @@ __HIGH_CODE
|
|||||||
void USB_IRQHandler(void) {
|
void USB_IRQHandler(void) {
|
||||||
uint8_t intflag = R8_USB_INT_FG;
|
uint8_t intflag = R8_USB_INT_FG;
|
||||||
clear_handshake_sent_flag();
|
clear_handshake_sent_flag();
|
||||||
|
#ifdef DEBUG
|
||||||
PRINT("\nusb: new interrupt\n");
|
PRINT("\nusb: new interrupt\n");
|
||||||
print_intflag_reg();
|
print_intflag_reg();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (intflag & RB_UIF_TRANSFER) {
|
if (intflag & RB_UIF_TRANSFER) {
|
||||||
|
#ifdef DEBUG
|
||||||
PRINT("usb: RX Length reg: %d\n", R8_USB_RX_LEN);
|
PRINT("usb: RX Length reg: %d\n", R8_USB_RX_LEN);
|
||||||
print_status_reg();
|
print_status_reg();
|
||||||
|
#endif
|
||||||
|
|
||||||
route_enpoints();
|
route_enpoints();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ USB_DEV_DESCR dev_desc = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* String Descriptor Zero, Specifying Languages Supported by the Device */
|
/* String Descriptor Zero, Specifying Languages Supported by the Device */
|
||||||
static uint8_t lang_desc[] = {
|
static uint16_t lang_desc[] = {
|
||||||
0x04, /* bLength */
|
0x04, /* bLength */
|
||||||
0x03, /* bDescriptorType */
|
0x03, /* bDescriptorType */
|
||||||
0x09, 0x04 /* wLANGID - en-US */
|
0x09, 0x04 /* wLANGID - en-US */
|
||||||
@@ -91,7 +91,7 @@ static void desc_config(USB_SETUP_REQ *request)
|
|||||||
|
|
||||||
static void desc_string(USB_SETUP_REQ *request)
|
static void desc_string(USB_SETUP_REQ *request)
|
||||||
{
|
{
|
||||||
uint8_t *string_index[32] = {
|
uint16_t *string_index[32] = {
|
||||||
lang_desc,
|
lang_desc,
|
||||||
vendor_info,
|
vendor_info,
|
||||||
product_info,
|
product_info,
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
void cdc_fill_IN(uint8_t *buf, uint8_t len);
|
void cdc_fill_IN(uint8_t *buf, uint8_t len);
|
||||||
int cdc_tx_poll(uint8_t *buf, int len, uint16_t timeout_ms);
|
int cdc_tx_poll(uint8_t *buf, int len, uint16_t timeout_ms);
|
||||||
void cdc_onWrite(void (*cb)(uint8_t *buf, uint16_t len));
|
void cdc_onWrite(int (*cb)(uint8_t *buf, uint16_t len));
|
||||||
|
|
||||||
void hiddev_fill_IN(uint8_t *buf, uint8_t len);
|
void hiddev_fill_IN(uint8_t *buf, uint8_t len);
|
||||||
int hiddev_tx_poll(uint8_t *buf, int len, uint16_t timeout_ms);
|
int hiddev_tx_poll(uint8_t *buf, int len, uint16_t timeout_ms);
|
||||||
void hiddev_onWrite(void (*cb)(uint8_t *buf, uint16_t len));
|
void hiddev_onWrite(int (*cb)(uint8_t *buf, uint16_t len));
|
||||||
|
|
||||||
void usb_start();
|
void usb_start();
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,8 @@ static void __handshake(uint8_t ep_num, int dir, int type, int tog, uint8_t len)
|
|||||||
if (ep_num > 7)
|
if (ep_num > 7)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char *type_mean[] = { "ACK", "NO_RESP", "NAK", "STALL"};
|
|
||||||
PRINT("Loaded %d byte, DATA%d with an %s to EP%dIN.\n",
|
PRINT("Loaded %d byte, DATA%d with an %s to EP%dIN.\n",
|
||||||
len, tog != 0, type_mean[type], ep_num);
|
len, tog != 0, ((char *[]){ "ACK", "NO_RESP", "NAK", "STALL"})[type], ep_num);
|
||||||
|
|
||||||
uint8_t ctrl = type << (dir ? 0 : 2);
|
uint8_t ctrl = type << (dir ? 0 : 2);
|
||||||
ctrl |= (tog) ? RB_UEP_T_TOG : RB_UEP_R_TOG;
|
ctrl |= (tog) ? RB_UEP_T_TOG : RB_UEP_R_TOG;
|
||||||
@@ -69,11 +68,11 @@ int handshake_sent()
|
|||||||
return res_sent;
|
return res_sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t *p_buf;
|
static const uint8_t *p_buf;
|
||||||
static uint16_t remain_len, req_len, _tog;
|
static uint16_t remain_len, req_len, _tog;
|
||||||
|
|
||||||
static uint16_t
|
static uint16_t
|
||||||
load_chunk(void *ep_buf, void *block, uint16_t block_len, uint16_t req_len,
|
load_chunk(void *ep_buf, const void *block, uint16_t block_len, uint16_t req_len,
|
||||||
int tog)
|
int tog)
|
||||||
{
|
{
|
||||||
_TRACE();
|
_TRACE();
|
||||||
@@ -119,7 +118,7 @@ int usb_load_next_chunk()
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
usb_start_load_block(void *ep_IN_buf, void *buf, uint16_t len, int tog)
|
usb_start_load_block(void *ep_IN_buf, const void *buf, uint16_t len, int tog)
|
||||||
{
|
{
|
||||||
_TRACE();
|
_TRACE();
|
||||||
req_len = len;
|
req_len = len;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ int if_cb_register(uint8_t if_num, void (*cb)(USB_SETUP_REQ *request));
|
|||||||
void dma_register(uint8_t endpoint_number, void *buf_addr);
|
void dma_register(uint8_t endpoint_number, void *buf_addr);
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
usb_start_load_block(void *ep_IN_buf, void *buf, uint16_t len, int tog);
|
usb_start_load_block(void *ep_IN_buf, const void *buf, uint16_t len, int tog);
|
||||||
void ctrl_start_load_block(void *buf, uint16_t len);
|
void ctrl_start_load_block(const void *buf, uint16_t len);
|
||||||
int usb_load_next_chunk();
|
int usb_load_next_chunk();
|
||||||
void usb_flush();
|
void usb_flush();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#define ALIGN_8BIT(x) (ALIGN_1BYTE(x) * 8)
|
#define ALIGN_8BIT(x) (ALIGN_1BYTE(x) * 8)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t *bits;
|
const uint8_t *bits;
|
||||||
int w; // Width
|
int w; // Width
|
||||||
int h; // Height
|
int h; // Height
|
||||||
int fh; // Frame height
|
int fh; // Frame height
|
||||||
|
|||||||
Reference in New Issue
Block a user