diff --git a/.vscode/settings.json b/.vscode/settings.json index 4f9e9321..892612c0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -38,6 +38,9 @@ "mlib_common.h": "c", "ios": "c", "limits": "c", - "algorithm": "c" + "algorithm": "c", + "app_status.h": "c", + "app_cmd.h": "c", + "rfid_main.h": "c" } } \ No newline at end of file diff --git a/fw/application/Makefile b/fw/application/Makefile index 611e42d7..71e4e42a 100644 --- a/fw/application/Makefile +++ b/fw/application/Makefile @@ -491,7 +491,10 @@ endif # cmd ifeq ($(BOARD),NEO) SRC_FILES += \ - $(CHAMELEON_ROOT)/application/src/app_cmd.c + $(CHAMELEON_ROOT)/application/src/app_cmd.c \ + $(CHAMELEON_ROOT)/application/src/rfid_main.c \ + $(CHAMELEON_ROOT)/application/src/utils/dataframe.c \ + $(CHAMELEON_ROOT)/application/src/bsp/bsp_wdt.c endif # Include folders common to all targets @@ -701,7 +704,9 @@ INC_FOLDERS += \ $(CHAMELEON_ROOT)/application/src/rfid \ $(CHAMELEON_ROOT)/application/src/rfid/nfctag \ $(CHAMELEON_ROOT)/application/src/rfid/nfctag/hf \ + $(CHAMELEON_ROOT)/application/src/rfid/nfctag/lf \ $(CHAMELEON_ROOT)/application/src/rfid/reader/hf \ + $(CHAMELEON_ROOT)/application/src/rfid/reader/lf \ $(CHAMELEON_ROOT)/application/src/utils \ $(CHAMELEON_ROOT)/application/src \ $(CHAMELEON_ROOT)/application/src/bsp \ diff --git a/fw/application/src/app/chameleon/port/fds_utils.c b/fw/application/src/app/chameleon/port/fds_utils.c index cf4ff100..ccad30a0 100644 --- a/fw/application/src/app/chameleon/port/fds_utils.c +++ b/fw/application/src/app/chameleon/port/fds_utils.c @@ -22,7 +22,7 @@ static void fds_map_file_name(uint16_t id, uint16_t key, char *path) { } } -bool fds_read_sync(uint16_t id, uint16_t key, uint16_t* max_length, uint8_t *buffer) { +bool fds_read_sync(uint16_t id, uint16_t key, uint16_t *max_length, uint8_t *buffer) { char path[VFS_MAX_PATH_LEN]; fds_map_file_name(id, key, path); int32_t bytes_read = vfs_get_default_driver()->read_file_data(path, buffer, *max_length); @@ -71,3 +71,13 @@ int32_t fds_write_meta(uint16_t id, uint16_t key, vfs_meta_t *meta) { vfs_meta_encode(meta_buf, sizeof(meta_buf), meta); return vfs_get_default_driver()->update_file_meta(path, meta_buf, sizeof(meta_buf)); } + +int fds_delete_sync(uint16_t id, uint16_t key) { + // FIXME + return 0; +} + +bool fds_wipe(void) { + // FIXME + return true; +} \ No newline at end of file diff --git a/fw/application/src/app/chameleon/port/fds_utils.h b/fw/application/src/app/chameleon/port/fds_utils.h index 8ddb1746..1729bd89 100644 --- a/fw/application/src/app/chameleon/port/fds_utils.h +++ b/fw/application/src/app/chameleon/port/fds_utils.h @@ -8,4 +8,10 @@ bool fds_config_file_exists(); int32_t fds_read_meta(uint16_t id, uint16_t key, vfs_meta_t *meta); int32_t fds_write_meta(uint16_t id, uint16_t key, vfs_meta_t *meta); -#endif \ No newline at end of file + +int fds_delete_sync(uint16_t id, uint16_t key); +bool fds_is_exists(uint16_t id, uint16_t key); +void fds_util_init(void); +void fds_gc_sync(void); +bool fds_wipe(void); +#endif \ No newline at end of file diff --git a/fw/application/src/main.c b/fw/application/src/main.c index f6015c05..a8de7381 100644 --- a/fw/application/src/main.c +++ b/fw/application/src/main.c @@ -101,6 +101,8 @@ #include "nfc_reader.h" #include "tusb.h" +#include "dataframe.h" + // #include "usbd.h" #define APP_SCHED_MAX_EVENT_SIZE 255 /**< Maximum size of scheduler events. */ @@ -322,6 +324,9 @@ int main(void) { // usb_tick(); tud_task(); // device task + + // Data pack process + data_frame_process(); #endif NRF_LOG_FLUSH(); if (NRF_LOG_PROCESS() == false) { diff --git a/fw/application/src/mod/tusb/family.c b/fw/application/src/mod/tusb/family.c index 6b700ddc..b885355b 100644 --- a/fw/application/src/mod/tusb/family.c +++ b/fw/application/src/mod/tusb/family.c @@ -37,6 +37,11 @@ #include "nrfx.h" #include "nrfx_power.h" +#include "tusb.h" + +#include "app_cmd.h" +#include "dataframe.h" + //--------------------------------------------------------------------+ // Forward USB interrupt events to TinyUSB IRQ Handler //--------------------------------------------------------------------+ @@ -58,6 +63,11 @@ enum { USB_EVT_DETECTED = 0, USB_EVT_REMOVED = 1, USB_EVT_READY = 2 }; //--------------------------------------------------------------------+ void board_init(void) { + + // init dataframe + // cmd callback register + on_data_frame_complete(on_data_frame_received); + // Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice // 2 is highest for application NVIC_SetPriority(USBD_IRQn, 2); @@ -115,3 +125,18 @@ void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) { (void)pc; (void)info; } + +void tud_cdc_rx_cb(uint8_t itf) { + // Take out the first byte first, WHY ??? + NRF_LOG_INFO("cdc rx: %d", tud_cdc_available()); + static uint8_t cdc_data_buffer[1]; + uint32_t ret = 0; + tud_cdc_read(cdc_data_buffer, 1); + do { + ret = tud_cdc_read(cdc_data_buffer, 1); + if (ret > 0) { + // The byte after success + data_frame_receive(cdc_data_buffer, 1); + } + } while (ret > 0); +} \ No newline at end of file diff --git a/fw/components/chameleon-ultra b/fw/components/chameleon-ultra index b6b2460c..ed55f548 160000 --- a/fw/components/chameleon-ultra +++ b/fw/components/chameleon-ultra @@ -1 +1 @@ -Subproject commit b6b2460cab911bda189ce0565ddf56b24f288bef +Subproject commit ed55f54868c1b293cb9eecb6c594d9a97bf4e19f