Skip to content

Commit

Permalink
cu port dev
Browse files Browse the repository at this point in the history
  • Loading branch information
solosky committed Aug 28, 2024
1 parent 14c1544 commit 3f35f8a
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
7 changes: 6 additions & 1 deletion fw/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down
12 changes: 11 additions & 1 deletion fw/application/src/app/chameleon/port/fds_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
8 changes: 7 additions & 1 deletion fw/application/src/app/chameleon/port/fds_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

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
5 changes: 5 additions & 0 deletions fw/application/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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) {
Expand Down
25 changes: 25 additions & 0 deletions fw/application/src/mod/tusb/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
//--------------------------------------------------------------------+
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

0 comments on commit 3f35f8a

Please sign in to comment.