Compare commits
9 Commits
master
...
AjoutManet
| Author | SHA1 | Date | |
|---|---|---|---|
| 2af1a59480 | |||
| 7f11642b10 | |||
| 6734142f03 | |||
| e5b55e420d | |||
| c3295f047b | |||
| 30b6c220f9 | |||
| 15d9064e69 | |||
| 85d7d9f1e1 | |||
| 2ab4f9a595 |
1
.vscode/c_cpp_properties.json
vendored
1
.vscode/c_cpp_properties.json
vendored
@ -6,7 +6,6 @@
|
|||||||
"${workspaceFolder}/build/generated/pico_base",
|
"${workspaceFolder}/build/generated/pico_base",
|
||||||
"${env:PICO_SDK_PATH}/src/**/include",
|
"${env:PICO_SDK_PATH}/src/**/include",
|
||||||
"${env:PICO_SDK_PATH}/lib/**/src",
|
"${env:PICO_SDK_PATH}/lib/**/src",
|
||||||
"${env:PICO_SDK_PATH}/lib/tinyusb/hw",
|
|
||||||
"${workspaceFolder}/lib/FatFs/source",
|
"${workspaceFolder}/lib/FatFs/source",
|
||||||
"${workspaceFolder}/lib/sd_driver"
|
"${workspaceFolder}/lib/sd_driver"
|
||||||
|
|
||||||
|
|||||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Pico Debug (Cortex-Debug with external OpenOCD)",
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"executable": "debug/Modele_RPiPico.elf",
|
|
||||||
"request": "launch",
|
|
||||||
"type": "cortex-debug",
|
|
||||||
"servertype": "external",
|
|
||||||
"gdbTarget": "localhost:3333",
|
|
||||||
"gdbPath": "gdb-multiarch",
|
|
||||||
"device": "RP2040",
|
|
||||||
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/RP2040.svd",
|
|
||||||
"runToEntryPoint": "main",
|
|
||||||
// Fix for no_flash binaries, where monitor reset halt doesn't do what is expected
|
|
||||||
// Also works fine for flash binaries
|
|
||||||
"overrideLaunchCommands": [
|
|
||||||
"monitor reset init",
|
|
||||||
"load debug/Modele_RPiPico.elf"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -14,7 +14,6 @@
|
|||||||
"sd_card.h": "c",
|
"sd_card.h": "c",
|
||||||
"rp2040_sdio.h": "c",
|
"rp2040_sdio.h": "c",
|
||||||
"util.h": "c",
|
"util.h": "c",
|
||||||
"stddef.h": "c",
|
"stddef.h": "c"
|
||||||
"log_usb.h": "c"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
12
.vscode/tasks.json
vendored
12
.vscode/tasks.json
vendored
@ -7,17 +7,7 @@
|
|||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": false
|
"isDefault": true
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "shell",
|
|
||||||
"command": "cd build; cmake ../ -DLOG=1; make Flash",
|
|
||||||
"label": "Flash with LOG=1",
|
|
||||||
"problemMatcher": [],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,9 +22,6 @@ target_sources(host_cdc_msc_hid PUBLIC
|
|||||||
cdc_app.c
|
cdc_app.c
|
||||||
diskio_USB.c
|
diskio_USB.c
|
||||||
diskio_SDIO.c
|
diskio_SDIO.c
|
||||||
com_usb.c
|
|
||||||
log.c
|
|
||||||
messagerie.c
|
|
||||||
lib/FatFs/source/ff.c
|
lib/FatFs/source/ff.c
|
||||||
lib/FatFs/source/ffsystem.c
|
lib/FatFs/source/ffsystem.c
|
||||||
lib/FatFs/source/diskio.c
|
lib/FatFs/source/diskio.c
|
||||||
@ -66,6 +63,7 @@ target_link_libraries( host_cdc_msc_hid PUBLIC
|
|||||||
hardware_spi
|
hardware_spi
|
||||||
hardware_sync
|
hardware_sync
|
||||||
pico_aon_timer
|
pico_aon_timer
|
||||||
|
pico_multicore
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
${HWDEP_LIBS}
|
${HWDEP_LIBS}
|
||||||
)
|
)
|
||||||
|
|||||||
92
cdc_app.c
92
cdc_app.c
@ -26,12 +26,6 @@
|
|||||||
|
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
#include "bsp/board_api.h"
|
#include "bsp/board_api.h"
|
||||||
#include "messagerie.h"
|
|
||||||
#include "com_usb.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
volatile bool in_transfert_cb = 0;
|
|
||||||
|
|
||||||
size_t get_console_inputs(uint8_t* buf, size_t bufsize) {
|
size_t get_console_inputs(uint8_t* buf, size_t bufsize) {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
@ -46,58 +40,6 @@ size_t get_console_inputs(uint8_t* buf, size_t bufsize) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void traiter_les_messages(uint8_t idx, struct message_t message){
|
|
||||||
// Debug
|
|
||||||
char message_en_clair[1024];
|
|
||||||
message_to_string(message, message_en_clair);
|
|
||||||
log_event(message_en_clair);
|
|
||||||
|
|
||||||
if(message.type == '>'){
|
|
||||||
char message_en_clair[1024];
|
|
||||||
message_to_string(message, message_en_clair);
|
|
||||||
printf("%s\n", message_en_clair);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(message.type == 'r'){
|
|
||||||
// Reception de données
|
|
||||||
set_carte_id(idx, message.id_carte);
|
|
||||||
struct log_buffer_t * log_buffer = get_buffer(idx);
|
|
||||||
for(int i=0; i<message.taille_donnees; i++){
|
|
||||||
log_buffer->tampon_echange[message.adresse_registre + i] = message.donnees[i];
|
|
||||||
}
|
|
||||||
/*char message_en_clair[1024];
|
|
||||||
message_to_string(message, message_en_clair);
|
|
||||||
log_event(message_en_clair);*/
|
|
||||||
//printf(">d:%d\n",log_buffer->tampon_echange[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(message.type == 'd'){
|
|
||||||
struct message_t message_emis;
|
|
||||||
char message_binaire[64];
|
|
||||||
uint32_t taille_message;
|
|
||||||
// Demande de données
|
|
||||||
uint8_t idx_lecture = get_carte_idx(message.id_carte);
|
|
||||||
|
|
||||||
if(idx_lecture == INVALID_ID){
|
|
||||||
printf("Erreur, no idx found\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct log_buffer_t * log_buffer = get_buffer(idx_lecture);
|
|
||||||
|
|
||||||
message_emis.type = 'r';
|
|
||||||
message_emis.id_carte = message.id_carte;
|
|
||||||
message_emis.adresse_registre = message.adresse_registre;
|
|
||||||
message_emis.taille_donnees = message.taille_donnees;
|
|
||||||
memcpy(message_emis.donnees, &(log_buffer->tampon_echange[message.adresse_registre]), message.taille_donnees);
|
|
||||||
|
|
||||||
taille_message = message_prepare_for_usb(message_emis, message_binaire);
|
|
||||||
|
|
||||||
tuh_cdc_write(idx, message_binaire, taille_message);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void cdc_app_task(void) {
|
void cdc_app_task(void) {
|
||||||
uint8_t buf[64 + 1]; // +1 for extra null character
|
uint8_t buf[64 + 1]; // +1 for extra null character
|
||||||
uint32_t const bufsize = sizeof(buf) - 1;
|
uint32_t const bufsize = sizeof(buf) - 1;
|
||||||
@ -106,7 +48,6 @@ void cdc_app_task(void) {
|
|||||||
buf[count] = 0;
|
buf[count] = 0;
|
||||||
|
|
||||||
// loop over all mounted interfaces
|
// loop over all mounted interfaces
|
||||||
// Envoi des données
|
|
||||||
for (uint8_t idx = 0; idx < CFG_TUH_CDC; idx++) {
|
for (uint8_t idx = 0; idx < CFG_TUH_CDC; idx++) {
|
||||||
if (tuh_cdc_mounted(idx)) {
|
if (tuh_cdc_mounted(idx)) {
|
||||||
// console --> cdc interfaces
|
// console --> cdc interfaces
|
||||||
@ -116,23 +57,6 @@ void cdc_app_task(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Analyse des données reçues lorsque la callback a été appelée
|
|
||||||
for (uint8_t idx = 0; idx < CFG_TUH_CDC; idx++) {
|
|
||||||
if (tuh_cdc_mounted(idx)) {
|
|
||||||
struct message_t message;
|
|
||||||
char chaine[1024];
|
|
||||||
char texte_log[255];
|
|
||||||
unsigned int position_chaine = 0, position_sous_chaine;
|
|
||||||
|
|
||||||
com_analyse(idx);
|
|
||||||
while(message_disponible()){
|
|
||||||
message = get_message();
|
|
||||||
traiter_les_messages(idx, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@ -141,11 +65,6 @@ void cdc_app_task(void) {
|
|||||||
|
|
||||||
// Invoked when received new data
|
// Invoked when received new data
|
||||||
void tuh_cdc_rx_cb(uint8_t idx) {
|
void tuh_cdc_rx_cb(uint8_t idx) {
|
||||||
if(in_transfert_cb){
|
|
||||||
printf("already processing data\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
in_transfert_cb = 1;
|
|
||||||
uint8_t buf[64 + 1]; // +1 for extra null character
|
uint8_t buf[64 + 1]; // +1 for extra null character
|
||||||
uint32_t const bufsize = sizeof(buf) - 1;
|
uint32_t const bufsize = sizeof(buf) - 1;
|
||||||
|
|
||||||
@ -153,9 +72,7 @@ void tuh_cdc_rx_cb(uint8_t idx) {
|
|||||||
uint32_t count = tuh_cdc_read(idx, buf, bufsize);
|
uint32_t count = tuh_cdc_read(idx, buf, bufsize);
|
||||||
buf[count] = 0;
|
buf[count] = 0;
|
||||||
|
|
||||||
com_add(idx, buf, count);
|
printf("%s", (char*) buf);
|
||||||
|
|
||||||
in_transfert_cb = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoked when a device with CDC interface is mounted
|
// Invoked when a device with CDC interface is mounted
|
||||||
@ -164,9 +81,8 @@ void tuh_cdc_mount_cb(uint8_t idx) {
|
|||||||
tuh_itf_info_t itf_info = {0};
|
tuh_itf_info_t itf_info = {0};
|
||||||
tuh_cdc_itf_get_info(idx, &itf_info);
|
tuh_cdc_itf_get_info(idx, &itf_info);
|
||||||
|
|
||||||
printf("CDC Interface is mounted: address = %u, itf_num = %u, idx = %u\r\n", itf_info.daddr,
|
printf("CDC Interface is mounted: address = %u, itf_num = %u\r\n", itf_info.daddr,
|
||||||
itf_info.desc.bInterfaceNumber, idx);
|
itf_info.desc.bInterfaceNumber);
|
||||||
com_create(idx);
|
|
||||||
|
|
||||||
#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
|
#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
|
||||||
// If CFG_TUH_CDC_LINE_CODING_ON_ENUM is defined, line coding will be set by tinyusb stack
|
// If CFG_TUH_CDC_LINE_CODING_ON_ENUM is defined, line coding will be set by tinyusb stack
|
||||||
@ -190,6 +106,4 @@ void tuh_cdc_umount_cb(uint8_t idx) {
|
|||||||
|
|
||||||
printf("CDC Interface is unmounted: address = %u, itf_num = %u\r\n", itf_info.daddr,
|
printf("CDC Interface is unmounted: address = %u, itf_num = %u\r\n", itf_info.daddr,
|
||||||
itf_info.desc.bInterfaceNumber);
|
itf_info.desc.bInterfaceNumber);
|
||||||
|
|
||||||
com_destroy(idx);
|
|
||||||
}
|
}
|
||||||
|
|||||||
228
com_usb.c
228
com_usb.c
@ -1,228 +0,0 @@
|
|||||||
#include <string.h>
|
|
||||||
#include "pico/platform/panic.h"
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
#include "messagerie.h"
|
|
||||||
#include "com_usb.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define TAMPON_TAILLE 1020
|
|
||||||
|
|
||||||
struct log_buffer_t log_buffer[NB_MAX_CDC_CONNEXION];
|
|
||||||
|
|
||||||
/// @brief Affecte l'id de la carte à une connexion CDC.
|
|
||||||
/// @param idx
|
|
||||||
/// @param carte_id
|
|
||||||
void set_carte_id(uint8_t idx, uint8_t carte_id){
|
|
||||||
struct log_buffer_t * p_log_bufffer;
|
|
||||||
p_log_bufffer = get_buffer(idx);
|
|
||||||
p_log_bufffer->carte_id = carte_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Obtient la connexion CDC à partir de l'id de la carte.
|
|
||||||
/// @param id_carte
|
|
||||||
/// @return idx pour établir la connexion CDC, INVALID_ID si non trouvé.
|
|
||||||
uint8_t get_carte_idx(uint8_t id_carte){
|
|
||||||
for(int i=0; i<NB_MAX_CDC_CONNEXION; i++){
|
|
||||||
if(log_buffer[i].carte_id == id_carte){
|
|
||||||
return log_buffer[i].idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("IDX not found - carte_id: %d\n", id_carte);
|
|
||||||
return INVALID_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct log_buffer_t * get_buffer(const char idx){
|
|
||||||
for (int i=0; i<NB_MAX_CDC_CONNEXION; i++){
|
|
||||||
if(log_buffer[i].idx == idx){
|
|
||||||
return &(log_buffer[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// TODO: panic ?
|
|
||||||
panic("Buffer IDX not found: %d\n", idx);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Initialisation des structure de reception des données USB-CDC
|
|
||||||
void com_init(){
|
|
||||||
for (int i=0; i<NB_MAX_CDC_CONNEXION; i++){
|
|
||||||
log_buffer[i].idx = INVALID_ID;
|
|
||||||
log_buffer[i].carte_id = INVALID_ID;
|
|
||||||
log_buffer[i].index_tampon_ecriture = 0;
|
|
||||||
log_buffer[i].index_tampon_lecture = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Affectation des tampons de reception à une liaison USB-CDC
|
|
||||||
/// @param idx :
|
|
||||||
void com_create(const char idx){
|
|
||||||
for (int i=0; i<NB_MAX_CDC_CONNEXION; i++){
|
|
||||||
if(log_buffer[i].idx == INVALID_ID){
|
|
||||||
log_buffer[i].idx = idx;
|
|
||||||
log_buffer[i].carte_id = INVALID_ID;
|
|
||||||
log_buffer[i].index_tampon_ecriture = 0;
|
|
||||||
log_buffer[i].index_tampon_lecture = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panic("Creation impossible: idx: %d\n", idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void com_destroy(const char idx){
|
|
||||||
struct log_buffer_t * p_log_bufffer;
|
|
||||||
p_log_bufffer = get_buffer(idx);
|
|
||||||
p_log_bufffer->idx = INVALID_ID;
|
|
||||||
printf("Destruction: idx: %d\n", idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Ajoute les données reçu au tampon tournant
|
|
||||||
/// @param idx Numéro de la liaison CDC
|
|
||||||
/// @param buffer Pointeur vers les données
|
|
||||||
/// @param buffer_size Taille des données
|
|
||||||
void com_add(const char idx, const char * buffer, uint16_t buffer_size){
|
|
||||||
struct log_buffer_t * log_buffer;
|
|
||||||
log_buffer = get_buffer(idx);
|
|
||||||
|
|
||||||
for(int i=0; i<buffer_size; i++){
|
|
||||||
log_buffer->index_tampon_ecriture = log_buffer->index_tampon_ecriture+1;
|
|
||||||
if(log_buffer->index_tampon_ecriture >= TAMPON_TAILLE){
|
|
||||||
log_buffer->index_tampon_ecriture = 0;
|
|
||||||
}
|
|
||||||
log_buffer->tampon[log_buffer->index_tampon_ecriture] = buffer[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Incrémente l'index du tampon tournant
|
|
||||||
/// @param index
|
|
||||||
/// @return
|
|
||||||
void increment_index(unsigned int *index){
|
|
||||||
*index = 1 + *index ;
|
|
||||||
if((*index) >= TAMPON_TAILLE){
|
|
||||||
*index = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief augmente la position l'index du tampon tournant
|
|
||||||
/// @param index
|
|
||||||
/// @return
|
|
||||||
void augmente_index(unsigned int *index, unsigned int offset){
|
|
||||||
*index = offset + *index ;
|
|
||||||
if((*index) >= TAMPON_TAILLE){
|
|
||||||
*index -= TAMPON_TAILLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void com_analyse(const char idx){
|
|
||||||
//printf("com_analyse %d\n", idx);
|
|
||||||
static absolute_time_t current_time_us, start_time_us=0;
|
|
||||||
current_time_us = get_absolute_time();
|
|
||||||
//printf(">a:%lld\n", current_time_us-start_time_us);
|
|
||||||
start_time_us = current_time_us;
|
|
||||||
|
|
||||||
// Les données sont dans le tampon tournant
|
|
||||||
// Nous les copions dans une seconde mémoire pour les analyser.
|
|
||||||
// Si un message est trouvé :
|
|
||||||
// - Celui-ci est ajouté à la liste des message à traiter
|
|
||||||
// - Nous avançons l'index de lecture du tampon cyclique
|
|
||||||
// Si nous arrivons à la fin du tampon cyclique, il n'y a plus rien à récupérer.
|
|
||||||
enum etat_message_t{
|
|
||||||
ETAT_MESSAGE_DEBUT,
|
|
||||||
ETAT_MESSAGE_TEXTE,
|
|
||||||
ETAT_MESSAGE_VALIDE
|
|
||||||
}etat_message;
|
|
||||||
|
|
||||||
struct log_buffer_t * p_log_bufffer;
|
|
||||||
char chaine[TAMPON_TAILLE];
|
|
||||||
char affiche_message[TAMPON_TAILLE];
|
|
||||||
struct message_t message;
|
|
||||||
|
|
||||||
unsigned int index, index_chaine;
|
|
||||||
p_log_bufffer = get_buffer(idx);
|
|
||||||
|
|
||||||
index = p_log_bufffer->index_tampon_lecture;
|
|
||||||
index_chaine = 0;
|
|
||||||
|
|
||||||
// Copie des données
|
|
||||||
if(index != p_log_bufffer->index_tampon_ecriture){
|
|
||||||
while(index != p_log_bufffer->index_tampon_ecriture){
|
|
||||||
chaine[index_chaine] = p_log_bufffer->tampon[index];
|
|
||||||
index_chaine++;
|
|
||||||
increment_index(&index);
|
|
||||||
}
|
|
||||||
chaine[index_chaine] = p_log_bufffer->tampon[index];
|
|
||||||
index_chaine++;
|
|
||||||
increment_index(&index);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lecture du message
|
|
||||||
message.type = 0;
|
|
||||||
message.idx = idx;
|
|
||||||
unsigned int fin_message = 0;
|
|
||||||
for(int i=0; i< index_chaine; i++){
|
|
||||||
unsigned int index_fin_message;
|
|
||||||
switch(etat_message){
|
|
||||||
case ETAT_MESSAGE_DEBUT:
|
|
||||||
if(chaine[i] == '>'){
|
|
||||||
message.type = '>';
|
|
||||||
message.taille_donnees = 0;
|
|
||||||
etat_message = ETAT_MESSAGE_TEXTE;
|
|
||||||
}
|
|
||||||
if(chaine[i] == 'd'){
|
|
||||||
// Est-ce que nous avons reçu le message en entier ?
|
|
||||||
if(i + 4 < index_chaine){
|
|
||||||
if(chaine[i+4] == 0){
|
|
||||||
// Message valide
|
|
||||||
message.type = 'd';
|
|
||||||
message.id_carte = chaine[i+1];
|
|
||||||
message.adresse_registre = chaine[i+2];
|
|
||||||
message.taille_donnees = chaine[i+3];
|
|
||||||
i = i + 4; // On se met à la fin du message
|
|
||||||
fin_message = i;
|
|
||||||
put_message(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(chaine[i] == 'r'){
|
|
||||||
// Est-ce que nous avons reçu l'entête du message ?
|
|
||||||
if(i + 4 < index_chaine){
|
|
||||||
message.type = 'r';
|
|
||||||
message.id_carte = chaine[i+1];
|
|
||||||
message.adresse_registre = chaine[i+2];
|
|
||||||
message.taille_donnees = chaine[i+3];
|
|
||||||
index_fin_message = i + message.taille_donnees + 4;
|
|
||||||
if(index_fin_message < index_chaine){
|
|
||||||
if(chaine[index_fin_message] == 0){
|
|
||||||
// Message valide
|
|
||||||
for(int index_donnees=0; index_donnees<message.taille_donnees; index_donnees++){
|
|
||||||
message.donnees[index_donnees] = chaine[index_donnees + i + 4];
|
|
||||||
}
|
|
||||||
i = index_fin_message; // On se met à la fin du message
|
|
||||||
fin_message = index_fin_message;
|
|
||||||
etat_message = ETAT_MESSAGE_DEBUT;
|
|
||||||
|
|
||||||
put_message(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ETAT_MESSAGE_TEXTE:
|
|
||||||
message.donnees[message.taille_donnees] = chaine[i];
|
|
||||||
message.taille_donnees++;
|
|
||||||
if(chaine[i] == '\n'){
|
|
||||||
// message valide.
|
|
||||||
message.donnees[message.taille_donnees] = '\0';
|
|
||||||
fin_message = i;
|
|
||||||
put_message(message);
|
|
||||||
|
|
||||||
etat_message = ETAT_MESSAGE_DEBUT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
augmente_index(&(p_log_bufffer->index_tampon_lecture), fin_message);
|
|
||||||
//printf("Fin com_analyse %d\n", idx);
|
|
||||||
}
|
|
||||||
21
com_usb.h
21
com_usb.h
@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
#define TAMPON_TAILLE 1020
|
|
||||||
#define NB_MAX_CDC_CONNEXION 10
|
|
||||||
#define INVALID_ID ((char)-1)
|
|
||||||
|
|
||||||
struct log_buffer_t{
|
|
||||||
char idx;
|
|
||||||
char carte_id;
|
|
||||||
char tampon[TAMPON_TAILLE]; // Tampon tournant - 1er niveau de tampon
|
|
||||||
char tampon_echange[TAMPON_TAILLE]; // Tampon contenant l'état de la carte
|
|
||||||
unsigned int index_tampon_ecriture, index_tampon_lecture;
|
|
||||||
};
|
|
||||||
|
|
||||||
void com_init(void);
|
|
||||||
void com_create(const char idx);
|
|
||||||
void com_destroy(const char idx);
|
|
||||||
void com_analyse(const char idx);
|
|
||||||
void com_add(const char idx, const char * buffer, uint16_t buffer_size);
|
|
||||||
struct log_buffer_t * get_buffer(const char idx);
|
|
||||||
void set_carte_id(uint8_t idx, uint8_t carte_id);
|
|
||||||
uint8_t get_carte_idx(uint8_t id_carte);
|
|
||||||
288
hid_app.c
288
hid_app.c
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bsp/board_api.h"
|
#include "bsp/board_api.h"
|
||||||
|
#include "hid_app.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@ -43,11 +44,107 @@ static struct
|
|||||||
{
|
{
|
||||||
uint8_t report_count;
|
uint8_t report_count;
|
||||||
tuh_hid_report_info_t report_info[MAX_REPORT];
|
tuh_hid_report_info_t report_info[MAX_REPORT];
|
||||||
|
uint16_t vid, pid;
|
||||||
}hid_info[CFG_TUH_HID];
|
}hid_info[CFG_TUH_HID];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void process_kbd_report(hid_keyboard_report_t const *report);
|
static void process_kbd_report(hid_keyboard_report_t const *report);
|
||||||
static void process_mouse_report(hid_mouse_report_t const * report);
|
static void process_mouse_report(hid_mouse_report_t const * report);
|
||||||
static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
|
static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
|
||||||
|
struct gamepad_data_t process_8bitpro_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
|
||||||
|
struct gamepad_data_t process_SonyDualShock4_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
|
||||||
|
struct gamepad_data_t process_BDA_NSW_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len);
|
||||||
|
void affiche_gamepad_data(struct gamepad_data_t _gamepad_report);
|
||||||
|
void refresh_gamepad_data(struct gamepad_data_t * gamepad_data);
|
||||||
|
|
||||||
|
// HID report from 8bitPro
|
||||||
|
|
||||||
|
typedef struct TU_ATTR_PACKED
|
||||||
|
{
|
||||||
|
uint8_t report_id;
|
||||||
|
uint b1:1; // Bouton A
|
||||||
|
uint b2:1; // Bouton B
|
||||||
|
uint b3:1; // 4 : ???
|
||||||
|
uint b4:1; // Bouton X
|
||||||
|
uint b5:1; // Bouton Y
|
||||||
|
uint b6:1; // 32 : ???
|
||||||
|
uint b7:1; // Bouton L
|
||||||
|
uint b8:1; // Bouton R
|
||||||
|
uint b9:1; // Bouton L2
|
||||||
|
uint b10:1; // Bouton R2
|
||||||
|
uint b11:1; // Start
|
||||||
|
uint b12:1; // Select
|
||||||
|
uint b13:1;
|
||||||
|
uint b14:1; // Click joystick gauche
|
||||||
|
uint b15:1; // Click joystick droit
|
||||||
|
uint b16:1; // 16 bits
|
||||||
|
uint8_t hat_switch; // OK
|
||||||
|
uint8_t x, y; // joystick Xg, Yg
|
||||||
|
uint8_t z, rz; // joystick Xd, Yd
|
||||||
|
|
||||||
|
uint8_t gachette_gauche; // ok
|
||||||
|
uint8_t gachette_droite; // ok
|
||||||
|
|
||||||
|
|
||||||
|
} _8bitpro_report_t ;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct TU_ATTR_PACKED
|
||||||
|
{
|
||||||
|
uint8_t report_id;
|
||||||
|
uint8_t x, y, z, rz; // joystick
|
||||||
|
uint hat_switch:4;
|
||||||
|
uint b1:1;
|
||||||
|
uint b2:1;
|
||||||
|
uint b3:1;
|
||||||
|
uint b4:1;
|
||||||
|
|
||||||
|
// 8 bits
|
||||||
|
uint b5:1;
|
||||||
|
uint b6:1;
|
||||||
|
uint b7:1;
|
||||||
|
uint b8:1;
|
||||||
|
uint b9:1;
|
||||||
|
uint b10:1;
|
||||||
|
uint b11:1;
|
||||||
|
uint b12:1; // 16 bits
|
||||||
|
|
||||||
|
uint data_1:8;
|
||||||
|
|
||||||
|
uint gachette_gauche:8;
|
||||||
|
uint gachette_droite:8;
|
||||||
|
|
||||||
|
|
||||||
|
} SonyDualShock4_report_t ;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct TU_ATTR_PACKED
|
||||||
|
{
|
||||||
|
uint b1:1; // Bouton Y
|
||||||
|
uint b2:1; // Bouton B
|
||||||
|
uint b3:1; // Bouton A
|
||||||
|
uint b4:1; // Bouton X
|
||||||
|
uint b5:1; // Bouton L
|
||||||
|
uint b6:1; // Bouton R
|
||||||
|
uint b7:1; // Bouton L2
|
||||||
|
uint b8:1; // Bouton R2
|
||||||
|
uint b9:1; // Bouton -
|
||||||
|
uint b10:1; // Bouton +
|
||||||
|
uint b11:1; // Bouton joystick droit
|
||||||
|
uint b12:1; // Bouton joystick gauche
|
||||||
|
uint b13:1; // Bouton Start
|
||||||
|
uint b14:1; // Bouton Select
|
||||||
|
uint b15:1; // --
|
||||||
|
uint b16:1; // --
|
||||||
|
uint8_t hat_switch; // OK
|
||||||
|
uint8_t x, y; // joystick Xg, Yg
|
||||||
|
uint8_t z, rz; // joystick Xd, Yd
|
||||||
|
|
||||||
|
} BDA_NSW_report_t ;
|
||||||
|
|
||||||
|
struct gamepad_data_t gamepad_data;
|
||||||
|
|
||||||
|
|
||||||
void hid_app_task(void)
|
void hid_app_task(void)
|
||||||
{
|
{
|
||||||
@ -67,6 +164,7 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
|
|||||||
{
|
{
|
||||||
printf("HID device address = %d, instance = %d is mounted\r\n", dev_addr, instance);
|
printf("HID device address = %d, instance = %d is mounted\r\n", dev_addr, instance);
|
||||||
|
|
||||||
|
|
||||||
// Interface protocol (hid_interface_protocol_enum_t)
|
// Interface protocol (hid_interface_protocol_enum_t)
|
||||||
const char* protocol_str[] = { "None", "Keyboard", "Mouse" };
|
const char* protocol_str[] = { "None", "Keyboard", "Mouse" };
|
||||||
uint8_t const itf_protocol = tuh_hid_interface_protocol(dev_addr, instance);
|
uint8_t const itf_protocol = tuh_hid_interface_protocol(dev_addr, instance);
|
||||||
@ -77,8 +175,26 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
|
|||||||
// Therefore for this simple example, we only need to parse generic report descriptor (with built-in parser)
|
// Therefore for this simple example, we only need to parse generic report descriptor (with built-in parser)
|
||||||
if ( itf_protocol == HID_ITF_PROTOCOL_NONE )
|
if ( itf_protocol == HID_ITF_PROTOCOL_NONE )
|
||||||
{
|
{
|
||||||
|
uint16_t vid, pid;
|
||||||
|
tuh_vid_pid_get(dev_addr, &vid, &pid);
|
||||||
|
printf("VID = %04x, PID = %04x\r\n", vid, pid);
|
||||||
|
hid_info[instance].vid = vid;
|
||||||
|
hid_info[instance].pid = pid;
|
||||||
|
|
||||||
|
|
||||||
hid_info[instance].report_count = tuh_hid_parse_report_descriptor(hid_info[instance].report_info, MAX_REPORT, desc_report, desc_len);
|
hid_info[instance].report_count = tuh_hid_parse_report_descriptor(hid_info[instance].report_info, MAX_REPORT, desc_report, desc_len);
|
||||||
printf("HID has %u reports \r\n", hid_info[instance].report_count);
|
printf("HID has %u reports \r\n", hid_info[instance].report_count);
|
||||||
|
|
||||||
|
for(int i=0; i< hid_info[instance].report_count; i++){
|
||||||
|
if(hid_info[instance].report_info->usage == 5 &&
|
||||||
|
hid_info[instance].report_info->usage_page == 1){
|
||||||
|
printf("Found Gamepad descriptor\n");
|
||||||
|
//create_gamepad_configuration(dev_addr, instance, desc_report, desc_len);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// request to receive report
|
// request to receive report
|
||||||
@ -114,7 +230,16 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// Generic report requires matching ReportID and contents with previous parsed report info
|
// Generic report requires matching ReportID and contents with previous parsed report info
|
||||||
process_generic_report(dev_addr, instance, report, len);
|
// Report - 2dc8:6002 8BitDo 8BitDo SN30 Pro+
|
||||||
|
if(hid_info[instance].vid == 0x2dc8 && hid_info[instance].pid == 0x6002){
|
||||||
|
gamepad_data = process_8bitpro_report(dev_addr, instance, report, len);
|
||||||
|
}else if(hid_info[instance].vid == 0x054c && hid_info[instance].pid == 0x05c4){
|
||||||
|
gamepad_data = process_SonyDualShock4_report(dev_addr, instance, report, len);
|
||||||
|
}else if(hid_info[instance].vid == 0x20d6 && hid_info[instance].pid == 0xa713){
|
||||||
|
gamepad_data = process_BDA_NSW_report(dev_addr, instance, report, len);
|
||||||
|
}else{
|
||||||
|
process_generic_report(dev_addr, instance, report, len);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +354,113 @@ static void process_mouse_report(hid_mouse_report_t const * report)
|
|||||||
cursor_movement(report->x, report->y, report->wheel);
|
cursor_movement(report->x, report->y, report->wheel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Report - 2dc8:6002 8BitDo 8BitDo SN30 Pro+
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
struct gamepad_data_t process_8bitpro_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len){
|
||||||
|
struct gamepad_data_t gamepad_data;
|
||||||
|
_8bitpro_report_t gamepad_report;
|
||||||
|
memcpy(&gamepad_report, report, sizeof(gamepad_report));
|
||||||
|
refresh_gamepad_data(&gamepad_data);
|
||||||
|
|
||||||
|
// Copie des données du rapport vers la structure standard
|
||||||
|
gamepad_data.joystick_x_gauche = gamepad_report.x;
|
||||||
|
gamepad_data.joystick_y_gauche = gamepad_report.y;
|
||||||
|
gamepad_data.joystick_x_droit = gamepad_report.z;
|
||||||
|
gamepad_data.joystick_y_droit = gamepad_report.rz;
|
||||||
|
gamepad_data.bouton_A = gamepad_report.b1;
|
||||||
|
gamepad_data.bouton_B = gamepad_report.b2;
|
||||||
|
gamepad_data.bouton_X = gamepad_report.b4;
|
||||||
|
gamepad_data.bouton_Y = gamepad_report.b5;
|
||||||
|
gamepad_data.bouton_L = gamepad_report.b7;
|
||||||
|
gamepad_data.bouton_R = gamepad_report.b8;
|
||||||
|
gamepad_data.bouton_L2 = gamepad_report.b9;
|
||||||
|
gamepad_data.bouton_R2 = gamepad_report.b10;
|
||||||
|
gamepad_data.bouton_Start = gamepad_report.b11;
|
||||||
|
gamepad_data.bouton_Select = gamepad_report.b12;
|
||||||
|
gamepad_data.bouton_joystick_gauche = gamepad_report.b15;
|
||||||
|
gamepad_data.bouton_joystick_droit = gamepad_report.b14;
|
||||||
|
gamepad_data.dpad = gamepad_report.hat_switch;
|
||||||
|
gamepad_data.gachette_droite = gamepad_report.gachette_droite;
|
||||||
|
gamepad_data.gachette_gauche = gamepad_report.gachette_gauche;
|
||||||
|
|
||||||
|
affiche_gamepad_data(gamepad_data);
|
||||||
|
return gamepad_data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// 054c:05c4 Sony Corp. DualShock 4 [CUH-ZCT1x]
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
struct gamepad_data_t process_SonyDualShock4_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len){
|
||||||
|
struct gamepad_data_t gamepad_data;
|
||||||
|
SonyDualShock4_report_t gamepad_report;
|
||||||
|
memcpy(&gamepad_report, report, sizeof(gamepad_report));
|
||||||
|
refresh_gamepad_data(&gamepad_data);
|
||||||
|
|
||||||
|
// Copie des données du rapport vers la structure standard
|
||||||
|
gamepad_data.joystick_x_gauche = gamepad_report.x;
|
||||||
|
gamepad_data.joystick_y_gauche = gamepad_report.y;
|
||||||
|
gamepad_data.joystick_x_droit = gamepad_report.z;
|
||||||
|
gamepad_data.joystick_y_droit = gamepad_report.rz;
|
||||||
|
gamepad_data.bouton_Y = gamepad_report.b4;
|
||||||
|
gamepad_data.bouton_A = gamepad_report.b3;
|
||||||
|
gamepad_data.bouton_B = gamepad_report.b2;
|
||||||
|
gamepad_data.bouton_X = gamepad_report.b1;
|
||||||
|
gamepad_data.bouton_joystick_droit = gamepad_report.b11;
|
||||||
|
gamepad_data.bouton_joystick_gauche = gamepad_report.b12;
|
||||||
|
gamepad_data.bouton_Select = gamepad_report.b10;
|
||||||
|
gamepad_data.bouton_Start = gamepad_report.b9;
|
||||||
|
gamepad_data.bouton_R2 = gamepad_report.b8;
|
||||||
|
gamepad_data.bouton_L2 = gamepad_report.b7;
|
||||||
|
gamepad_data.bouton_R = gamepad_report.b6;
|
||||||
|
gamepad_data.bouton_L = gamepad_report.b5;
|
||||||
|
gamepad_data.dpad = gamepad_report.hat_switch;
|
||||||
|
gamepad_data.gachette_droite = gamepad_report.gachette_droite;
|
||||||
|
gamepad_data.gachette_gauche = gamepad_report.gachette_gauche;
|
||||||
|
|
||||||
|
affiche_gamepad_data(gamepad_data);
|
||||||
|
return gamepad_data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Report - 20d6:a713 BDA NSW wired controller
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
struct gamepad_data_t process_BDA_NSW_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len){
|
||||||
|
struct gamepad_data_t gamepad_data;
|
||||||
|
BDA_NSW_report_t gamepad_report;
|
||||||
|
memcpy(&gamepad_report, report, sizeof(gamepad_report));
|
||||||
|
refresh_gamepad_data(&gamepad_data);
|
||||||
|
|
||||||
|
// Copie des données du rapport vers la structure standard
|
||||||
|
gamepad_data.joystick_x_gauche = gamepad_report.x;
|
||||||
|
gamepad_data.joystick_y_gauche = gamepad_report.y;
|
||||||
|
gamepad_data.joystick_x_droit = gamepad_report.z;
|
||||||
|
gamepad_data.joystick_y_droit = gamepad_report.rz;
|
||||||
|
gamepad_data.bouton_Y = gamepad_report.b1;
|
||||||
|
gamepad_data.bouton_B = gamepad_report.b2;
|
||||||
|
gamepad_data.bouton_A = gamepad_report.b3;
|
||||||
|
gamepad_data.bouton_X = gamepad_report.b4;
|
||||||
|
gamepad_data.bouton_L = gamepad_report.b5;
|
||||||
|
gamepad_data.bouton_R = gamepad_report.b6;
|
||||||
|
gamepad_data.bouton_L2 = gamepad_report.b7;
|
||||||
|
gamepad_data.bouton_R2 = gamepad_report.b8;
|
||||||
|
|
||||||
|
|
||||||
|
gamepad_data.bouton_joystick_gauche = gamepad_report.b12;
|
||||||
|
gamepad_data.bouton_joystick_droit = gamepad_report.b11;
|
||||||
|
|
||||||
|
gamepad_data.bouton_Start = gamepad_report.b13;
|
||||||
|
gamepad_data.bouton_Select = gamepad_report.b14;
|
||||||
|
|
||||||
|
gamepad_data.dpad = gamepad_report.hat_switch;
|
||||||
|
|
||||||
|
affiche_gamepad_data(gamepad_data);
|
||||||
|
return gamepad_data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Generic Report
|
// Generic Report
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@ -239,6 +471,14 @@ static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t c
|
|||||||
uint8_t const rpt_count = hid_info[instance].report_count;
|
uint8_t const rpt_count = hid_info[instance].report_count;
|
||||||
tuh_hid_report_info_t* rpt_info_arr = hid_info[instance].report_info;
|
tuh_hid_report_info_t* rpt_info_arr = hid_info[instance].report_info;
|
||||||
tuh_hid_report_info_t* rpt_info = NULL;
|
tuh_hid_report_info_t* rpt_info = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
//printf("HID Report brut\n");
|
||||||
|
printf(">a:1\n");
|
||||||
|
for(int i=0; i< len; i++){
|
||||||
|
printf("0x%X ", report[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
if ( rpt_count == 1 && rpt_info_arr[0].report_id == 0)
|
if ( rpt_count == 1 && rpt_info_arr[0].report_id == 0)
|
||||||
{
|
{
|
||||||
@ -292,7 +532,53 @@ static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t c
|
|||||||
process_mouse_report( (hid_mouse_report_t const*) report );
|
process_mouse_report( (hid_mouse_report_t const*) report );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HID_USAGE_DESKTOP_GAMEPAD:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void process_gamepad_report(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void affiche_gamepad_data(struct gamepad_data_t _gamepad_report){
|
||||||
|
printf(">jxd:%d\n", _gamepad_report.joystick_x_gauche);
|
||||||
|
printf(">jyd:%d\n", _gamepad_report.joystick_y_gauche);
|
||||||
|
printf(">jxg:%d\n", _gamepad_report.joystick_x_droit);
|
||||||
|
printf(">jyg:%d\n", _gamepad_report.joystick_y_droit);
|
||||||
|
printf(">hat:%d\n", _gamepad_report.dpad);
|
||||||
|
|
||||||
|
printf(">ba:%d\n", _gamepad_report.bouton_A);
|
||||||
|
printf(">bb:%d\n", _gamepad_report.bouton_B);
|
||||||
|
printf(">bx:%d\n", _gamepad_report.bouton_X);
|
||||||
|
printf(">by:%d\n", _gamepad_report.bouton_Y);
|
||||||
|
printf(">bstart:%d\n", _gamepad_report.bouton_Start);
|
||||||
|
printf(">bselect:%d\n", _gamepad_report.bouton_Select);
|
||||||
|
printf(">bl:%d\n", _gamepad_report.bouton_L);
|
||||||
|
printf(">br:%d\n", _gamepad_report.bouton_R);
|
||||||
|
printf(">bl2:%d\n", _gamepad_report.bouton_L2);
|
||||||
|
printf(">br2:%d\n", _gamepad_report.bouton_R2);
|
||||||
|
printf(">bjg:%d\n", _gamepad_report.bouton_joystick_droit);
|
||||||
|
printf(">bjd:%d\n", _gamepad_report.bouton_joystick_gauche);
|
||||||
|
|
||||||
|
//printf(">data1:%d\n", _gamepad_report.data_1);
|
||||||
|
|
||||||
|
printf(">gd:%d\n", _gamepad_report.gachette_droite);
|
||||||
|
printf(">gg:%d\n", _gamepad_report.gachette_gauche);
|
||||||
|
}
|
||||||
|
|
||||||
|
void refresh_gamepad_data(struct gamepad_data_t * gamepad_data){
|
||||||
|
gamepad_data->temps_ms = (uint32_t) get_absolute_time() / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool gamepad_connecte(){
|
||||||
|
return ((get_absolute_time() / 1000) - gamepad_data.temps_ms < 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct gamepad_data_t get_gamepad_data(){
|
||||||
|
return gamepad_data;
|
||||||
|
}
|
||||||
29
hid_app.h
Normal file
29
hid_app.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct gamepad_data_t{
|
||||||
|
uint32_t temps_ms;
|
||||||
|
|
||||||
|
uint8_t joystick_x_gauche;
|
||||||
|
uint8_t joystick_y_gauche;
|
||||||
|
uint8_t joystick_x_droit;
|
||||||
|
uint8_t joystick_y_droit;
|
||||||
|
uint8_t gachette_gauche;
|
||||||
|
uint8_t gachette_droite;
|
||||||
|
uint8_t dpad;
|
||||||
|
bool bouton_A;
|
||||||
|
bool bouton_B;
|
||||||
|
bool bouton_X;
|
||||||
|
bool bouton_Y;
|
||||||
|
bool bouton_Start;
|
||||||
|
bool bouton_Select;
|
||||||
|
bool bouton_L;
|
||||||
|
bool bouton_L2;
|
||||||
|
bool bouton_R;
|
||||||
|
bool bouton_R2;
|
||||||
|
bool bouton_joystick_gauche;
|
||||||
|
bool bouton_joystick_droit;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool gamepad_connecte();
|
||||||
|
struct gamepad_data_t get_gamepad_data();
|
||||||
@ -50,6 +50,7 @@ DSTATUS disk_initialize (
|
|||||||
{
|
{
|
||||||
DSTATUS stat;
|
DSTATUS stat;
|
||||||
int result;
|
int result;
|
||||||
|
printf("disk_initialize : %d\n", pdrv);
|
||||||
if(pdrv >= DEV_SDIO_MIN && pdrv <= DEV_SDIO_MAX){
|
if(pdrv >= DEV_SDIO_MIN && pdrv <= DEV_SDIO_MAX){
|
||||||
SDIO_disk_initialize(pdrv - DEV_SDIO_MIN);
|
SDIO_disk_initialize(pdrv - DEV_SDIO_MIN);
|
||||||
return 0; // OK
|
return 0; // OK
|
||||||
|
|||||||
203
log.c
203
log.c
@ -1,203 +0,0 @@
|
|||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "pico/stdlib.h"
|
|
||||||
|
|
||||||
#include "ff.h"
|
|
||||||
|
|
||||||
#define TAILLE_TAMPON_LECTURE 10
|
|
||||||
#define TAILLE_TAMPON_ECRITURE 0x8000
|
|
||||||
|
|
||||||
struct tampon_ecriture_t{
|
|
||||||
char tampon0[TAILLE_TAMPON_ECRITURE], tampon1[TAILLE_TAMPON_ECRITURE];
|
|
||||||
char * tampon_a_ecrire, *tampon_actif;
|
|
||||||
unsigned int index_tampon, taille_tampon_a_ecrire;
|
|
||||||
FIL fp;
|
|
||||||
} tampon_event, tampon_telemetrie;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ecrit_tampon_dans_sd(struct tampon_ecriture_t * tampon_ecriture){
|
|
||||||
if(tampon_ecriture->tampon_a_ecrire != NULL){
|
|
||||||
absolute_time_t current_time, start_time;
|
|
||||||
unsigned int nb_ecrit;
|
|
||||||
start_time = get_absolute_time();
|
|
||||||
f_write(&tampon_ecriture->fp, tampon_ecriture->tampon_a_ecrire, tampon_ecriture->taille_tampon_a_ecrire, &nb_ecrit);
|
|
||||||
f_sync(&tampon_ecriture->fp);
|
|
||||||
current_time = get_absolute_time();
|
|
||||||
printf(">sd(Mo/s):%d:%.3f\n", (int)(current_time/1000), (float)(nb_ecrit) / (float)(current_time - start_time));
|
|
||||||
//printf(">Octets:%d:%d\n", (int)(current_time/1000), nb_ecrit);
|
|
||||||
//printf(">temps_sd:%d:%lld\n", (int)(current_time/1000), current_time - start_time);
|
|
||||||
tampon_ecriture->tampon_a_ecrire = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void routine_log_sd(void){
|
|
||||||
while(1){
|
|
||||||
ecrit_tampon_dans_sd(&tampon_event);
|
|
||||||
ecrit_tampon_dans_sd(&tampon_telemetrie);
|
|
||||||
sleep_ms(10);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void ajout_texte_a_tampon(const char *chaine, struct tampon_ecriture_t * tampon_ecriture){
|
|
||||||
if(tampon_ecriture->index_tampon + strlen(chaine) > TAILLE_TAMPON_ECRITURE){
|
|
||||||
tampon_ecriture->tampon_a_ecrire = tampon_ecriture->tampon_actif;
|
|
||||||
// permutation du tampon actif
|
|
||||||
// indication du tampon à écrire
|
|
||||||
// remise à 0 de l'index du tampon
|
|
||||||
if(tampon_ecriture->tampon_actif == tampon_ecriture->tampon0){
|
|
||||||
tampon_ecriture->tampon_actif = tampon_ecriture->tampon1;
|
|
||||||
tampon_ecriture->tampon_a_ecrire = tampon_ecriture->tampon0;
|
|
||||||
}else{
|
|
||||||
tampon_ecriture->tampon_actif = tampon_ecriture->tampon0;
|
|
||||||
tampon_ecriture->tampon_a_ecrire = tampon_ecriture->tampon1;
|
|
||||||
}
|
|
||||||
tampon_ecriture->taille_tampon_a_ecrire = tampon_ecriture->index_tampon;
|
|
||||||
tampon_ecriture->index_tampon = 0;
|
|
||||||
tampon_ecriture->tampon_actif[0] = 0;
|
|
||||||
}
|
|
||||||
strcat(tampon_ecriture->tampon_actif, chaine);
|
|
||||||
tampon_ecriture->index_tampon += strlen(chaine);
|
|
||||||
ecrit_tampon_dans_sd(tampon_ecriture);
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_tampon_ecriture( struct tampon_ecriture_t * tampon_ecriture ){
|
|
||||||
tampon_ecriture->tampon_actif = tampon_ecriture->tampon0;
|
|
||||||
tampon_ecriture->index_tampon = 0;
|
|
||||||
tampon_ecriture->tampon_a_ecrire = NULL;
|
|
||||||
tampon_ecriture->tampon0[0];
|
|
||||||
tampon_ecriture->tampon1[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
char * get_tampon_inactif(struct tampon_ecriture_t * tampon_ecriture){
|
|
||||||
if(tampon_ecriture->index_tampon){
|
|
||||||
return tampon_ecriture->tampon0;
|
|
||||||
}
|
|
||||||
return tampon_ecriture->tampon1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char * get_tampon_actif(struct tampon_ecriture_t * tampon_ecriture){
|
|
||||||
if(tampon_ecriture->index_tampon){
|
|
||||||
return tampon_ecriture->tampon0;
|
|
||||||
}
|
|
||||||
return tampon_ecriture->tampon1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_message(const char * message, struct tampon_ecriture_t * tampon_ecriture);
|
|
||||||
|
|
||||||
int log_running = 0;
|
|
||||||
|
|
||||||
|
|
||||||
void erreur(char * message){
|
|
||||||
while(1){
|
|
||||||
puts(message);
|
|
||||||
sleep_ms(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_init(const char * drive_path){
|
|
||||||
FIL fp;
|
|
||||||
FRESULT result;
|
|
||||||
uint16_t num_log;
|
|
||||||
unsigned int nb_lu;
|
|
||||||
char message_erreur[150];
|
|
||||||
char tampon[TAILLE_TAMPON_LECTURE];
|
|
||||||
|
|
||||||
// Ouverture de num_log.txt
|
|
||||||
char path_num_log[20], path[30];
|
|
||||||
strcpy(path_num_log, drive_path);
|
|
||||||
strcat(path_num_log, "/num_log.txt");
|
|
||||||
result = f_open(&fp, path_num_log, FA_OPEN_EXISTING | FA_READ);
|
|
||||||
num_log = 0;
|
|
||||||
if(!result){
|
|
||||||
// le fichier existe, lisons-le
|
|
||||||
result = f_read (&fp, tampon, TAILLE_TAMPON_LECTURE, &nb_lu);
|
|
||||||
if(!result){
|
|
||||||
// lisons le nombre dans le tampon
|
|
||||||
for(int index = 0; index < TAILLE_TAMPON_LECTURE; index++){
|
|
||||||
if(tampon[index] >= '0' && tampon[index] <= '9'){
|
|
||||||
num_log = num_log * 10 + tampon[index] - '0';
|
|
||||||
}else{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
num_log++;
|
|
||||||
}else{
|
|
||||||
sprintf(message_erreur, "Échec à la lecture du fichier %s: %d", path_num_log, result);
|
|
||||||
erreur(message_erreur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f_close(&fp);
|
|
||||||
// Écriture de num_log dans num_log.txt
|
|
||||||
sprintf(tampon, "%d\n", num_log);
|
|
||||||
printf("%s", tampon);
|
|
||||||
result = f_open(&fp, path_num_log, FA_CREATE_ALWAYS | FA_WRITE);
|
|
||||||
if(!result){
|
|
||||||
result = f_write(&fp, tampon, strlen(tampon), &nb_lu);
|
|
||||||
if(result){
|
|
||||||
sprintf(message_erreur, "Échec à l'écriture du fichier %s: %d", path_num_log, result);
|
|
||||||
erreur(message_erreur);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
sprintf(message_erreur, "Échec à l'ouverture du fichier %s: %d", path_num_log, result);
|
|
||||||
erreur(message_erreur);
|
|
||||||
}
|
|
||||||
f_close(&fp);
|
|
||||||
|
|
||||||
printf("num_log:%d\n", num_log);
|
|
||||||
|
|
||||||
|
|
||||||
init_tampon_ecriture(&tampon_event);
|
|
||||||
init_tampon_ecriture(&tampon_telemetrie);
|
|
||||||
|
|
||||||
// Ouverture du fichier de log
|
|
||||||
sprintf(path, "%s%s%03d.txt", drive_path, "data", num_log);
|
|
||||||
printf("path: %s\n", path);
|
|
||||||
result = f_open(&(tampon_telemetrie.fp), path, FA_CREATE_ALWAYS | FA_WRITE);
|
|
||||||
if(result){
|
|
||||||
sprintf(message_erreur, "Échec à l'ouverture du fichier %s: %d", path, result);
|
|
||||||
erreur(message_erreur);
|
|
||||||
}
|
|
||||||
result = f_write(&(tampon_telemetrie.fp), "Début du fichier\n", strlen("Début du fichier"), &nb_lu);
|
|
||||||
f_sync(&(tampon_telemetrie.fp));
|
|
||||||
printf("Fichier créé: %s\n", path);
|
|
||||||
|
|
||||||
// Ouverture du fichier de telemetrie
|
|
||||||
sprintf(path, "%s%s%03d.txt", drive_path, "event", num_log);
|
|
||||||
result = f_open(&(tampon_event.fp), path, FA_CREATE_ALWAYS | FA_WRITE);
|
|
||||||
result |= f_write(&(tampon_event.fp), "Début du fichier\n", strlen("Début du fichier"), &nb_lu);
|
|
||||||
if(result){
|
|
||||||
sprintf(message_erreur, "Échec à l'ouverture du fichier %s: %d", path, result);
|
|
||||||
erreur(message_erreur);
|
|
||||||
}
|
|
||||||
printf("Fichier créé: %s\n", path);
|
|
||||||
|
|
||||||
|
|
||||||
log_running = 1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_telemetrie(char * message){
|
|
||||||
log_message(message, &tampon_telemetrie);
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_event(char * message){
|
|
||||||
log_message(message, &tampon_event);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_message(const char * message, struct tampon_ecriture_t * tampon_ecriture){
|
|
||||||
if(log_running){
|
|
||||||
absolute_time_t current_time;
|
|
||||||
char temps[20];
|
|
||||||
|
|
||||||
current_time = get_absolute_time();
|
|
||||||
|
|
||||||
sprintf(temps, "%lld:", current_time);
|
|
||||||
ajout_texte_a_tampon(temps, tampon_ecriture);
|
|
||||||
ajout_texte_a_tampon(message, tampon_ecriture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
4
log.h
4
log.h
@ -1,4 +0,0 @@
|
|||||||
void log_init(const char * drive_path);
|
|
||||||
void log_telemetrie(char * message);
|
|
||||||
void log_event(char * message);
|
|
||||||
void routine_log_sd(void);
|
|
||||||
42
main.c
42
main.c
@ -28,13 +28,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "bsp/board_api.h"
|
#include "bsp/board_api.h"
|
||||||
|
#include "hid_app.h"
|
||||||
#include "lib/sd_driver/sd_card.h"
|
#include "lib/sd_driver/sd_card.h"
|
||||||
|
#include "pico/multicore.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
#include "f_util.h"
|
#include "f_util.h"
|
||||||
#include "log.h"
|
|
||||||
#include "com_usb.h"
|
|
||||||
#include "pico/multicore.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||||
@ -104,16 +103,31 @@ sd_card_t* sd_get_by_num(size_t num) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usb_routine(){
|
||||||
|
while (1) {
|
||||||
|
// tinyusb host task
|
||||||
|
tuh_task();
|
||||||
|
|
||||||
|
led_blinking_task();
|
||||||
|
cdc_app_task();
|
||||||
|
hid_app_task();
|
||||||
|
|
||||||
|
|
||||||
|
//log_to_sd(big_big_buffer);
|
||||||
|
//log_to_usb(big_big_buffer); // à commenter pour obtenir un test juste sur la carte SD.(ou simplement ne pas brancher de clé USB)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------- MAIN -------------*/
|
/*------------- MAIN -------------*/
|
||||||
int main(void) {
|
int main(void) {
|
||||||
board_init();
|
board_init();
|
||||||
|
gpio_set_function(12, UART_FUNCSEL_NUM(uart0, 12));
|
||||||
printf("TinyUSB Host CDC MSC HID - Logs\r\n");
|
gpio_set_function(13, UART_FUNCSEL_NUM(uart0, 13));
|
||||||
|
printf("TinyUSB Host CDC MSC HID Example - test comparatif\r\n");
|
||||||
|
|
||||||
// init host stack on configured roothub port
|
// init host stack on configured roothub port
|
||||||
// à mettre avant tuh_init
|
|
||||||
com_init();
|
|
||||||
tuh_init(BOARD_TUH_RHPORT);
|
tuh_init(BOARD_TUH_RHPORT);
|
||||||
|
|
||||||
if (board_init_after_tusb) {
|
if (board_init_after_tusb) {
|
||||||
@ -146,9 +160,7 @@ int main(void) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_init(drive_path);
|
|
||||||
|
|
||||||
//multicore_launch_core1(routine_log_sd);
|
|
||||||
|
|
||||||
|
|
||||||
const char buffer[]= "Ceci est le test de Poivron Robotique\n";
|
const char buffer[]= "Ceci est le test de Poivron Robotique\n";
|
||||||
@ -160,14 +172,22 @@ int main(void) {
|
|||||||
strcat(big_big_buffer, buffer);
|
strcat(big_big_buffer, buffer);
|
||||||
size += strlen(buffer);
|
size += strlen(buffer);
|
||||||
}
|
}
|
||||||
|
multicore_launch_core1(usb_routine);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// tinyusb host task
|
// tinyusb host task
|
||||||
tuh_task();
|
/*tuh_task();
|
||||||
|
|
||||||
led_blinking_task();
|
led_blinking_task();
|
||||||
cdc_app_task();
|
cdc_app_task();
|
||||||
hid_app_task();
|
hid_app_task();*/
|
||||||
|
if(gamepad_connecte()){
|
||||||
|
struct gamepad_data_t gamepad_data;
|
||||||
|
gamepad_data = get_gamepad_data();
|
||||||
|
printf(">joystique_xd:%d\n", gamepad_data.joystick_x_gauche);
|
||||||
|
}
|
||||||
|
printf(">gc:%d\n", gamepad_connecte());
|
||||||
|
sleep_ms(1);
|
||||||
//log_to_sd(big_big_buffer);
|
//log_to_sd(big_big_buffer);
|
||||||
//log_to_usb(big_big_buffer); // à commenter pour obtenir un test juste sur la carte SD.(ou simplement ne pas brancher de clé USB)
|
//log_to_usb(big_big_buffer); // à commenter pour obtenir un test juste sur la carte SD.(ou simplement ne pas brancher de clé USB)
|
||||||
|
|
||||||
|
|||||||
106
messagerie.c
106
messagerie.c
@ -1,106 +0,0 @@
|
|||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "messagerie.h"
|
|
||||||
|
|
||||||
#define NB_MAX_MESSAGE 30
|
|
||||||
|
|
||||||
int index_message=0;
|
|
||||||
struct message_t message_liste[NB_MAX_MESSAGE];
|
|
||||||
|
|
||||||
/// @brief Renvoi 1 si des message sont disponibles
|
|
||||||
/// @return
|
|
||||||
bool message_disponible(){
|
|
||||||
return (index_message != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Renvoi un message à traiter, à n'appeler que si message_disponible() renvoie 1
|
|
||||||
/// @return Message
|
|
||||||
struct message_t get_message(){
|
|
||||||
index_message = index_message - 1;
|
|
||||||
return message_liste[index_message];
|
|
||||||
}
|
|
||||||
|
|
||||||
void put_message(struct message_t message){
|
|
||||||
if(index_message < NB_MAX_MESSAGE-1){
|
|
||||||
message_liste[index_message] = message;
|
|
||||||
index_message = index_message + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Remplit chaine_texte avec les données du message présentées en ascii
|
|
||||||
/// @param message structure de transfert entre les cartes
|
|
||||||
/// @param chaine_texte doit être allouée, prévoir 64 octets. Attention ce ne sera pas suffisant dans tous les cas
|
|
||||||
/// @return 0 si tout s'est bien passé, 1 sinon
|
|
||||||
char message_to_string(struct message_t message, char * chaine_texte){
|
|
||||||
if(message.type == 'r' || message.type == 'w' || message.type == 'd'){
|
|
||||||
sprintf(chaine_texte, "%c: id_carte: %d, registre: %d, taille: %d", message.type, message.id_carte, message.adresse_registre, message.taille_donnees);
|
|
||||||
|
|
||||||
if(message.type == 'r' || message.type == 'w' ){
|
|
||||||
char value[5];
|
|
||||||
strcat(chaine_texte, ", données: ");
|
|
||||||
for(int i=0; i< message.taille_donnees; i++){
|
|
||||||
sprintf(value, "%d ", message.donnees[i]);
|
|
||||||
strcat(chaine_texte, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strcat(chaine_texte, "\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(message.type == '>'){
|
|
||||||
chaine_texte[0] = '>';
|
|
||||||
chaine_texte[1] = '\0';
|
|
||||||
strcat(chaine_texte, message.donnees);
|
|
||||||
strcat(chaine_texte, "\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief remplit la mémoire message_binaire pour les données du message en usb
|
|
||||||
/// @param message
|
|
||||||
/// @param message_binaire
|
|
||||||
/// @return nombre d'octet à envoyer
|
|
||||||
uint16_t message_prepare_for_usb(struct message_t message, uint8_t * message_binaire){
|
|
||||||
switch (message.type)
|
|
||||||
{
|
|
||||||
case 'r':
|
|
||||||
message_binaire[0] = message.type;
|
|
||||||
message_binaire[1] = message.id_carte;
|
|
||||||
message_binaire[2] = message.adresse_registre;
|
|
||||||
message_binaire[3] = message.taille_donnees;
|
|
||||||
for(int i=0; i < message.taille_donnees; i++){
|
|
||||||
message_binaire[4+i] = message.donnees[i];
|
|
||||||
}
|
|
||||||
message_binaire[4+message.taille_donnees] = 0;
|
|
||||||
|
|
||||||
return (4 + message.taille_donnees + 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd':
|
|
||||||
message_binaire[0] = message.type;
|
|
||||||
message_binaire[1] = message.id_carte;
|
|
||||||
message_binaire[2] = message.adresse_registre;
|
|
||||||
message_binaire[3] = message.taille_donnees;
|
|
||||||
message_binaire[4] = 0;
|
|
||||||
return 5;
|
|
||||||
|
|
||||||
case 'w':
|
|
||||||
message_binaire[0] = message.type;
|
|
||||||
message_binaire[1] = message.id_carte;
|
|
||||||
message_binaire[2] = message.adresse_registre;
|
|
||||||
message_binaire[3] = message.taille_donnees;
|
|
||||||
for(int i=0; i < message.taille_donnees; i++){
|
|
||||||
message_binaire[4+i] = message.donnees[i];
|
|
||||||
}
|
|
||||||
message_binaire[4+message.taille_donnees] = 0;
|
|
||||||
return (4 + message.taille_donnees);
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
18
messagerie.h
18
messagerie.h
@ -1,18 +0,0 @@
|
|||||||
#include "pico/stdlib.h"
|
|
||||||
|
|
||||||
struct message_t{
|
|
||||||
uint8_t type; // 'd' pour demande, 'r' pour une réception de données, 'w' pour écrire des données, '>' pour des logs
|
|
||||||
uint8_t id_carte; // Identifiant de la carte (on reprend les adresses I2C)
|
|
||||||
uint8_t adresse_registre; // Adresse du registre lu
|
|
||||||
uint8_t taille_donnees;
|
|
||||||
uint8_t donnees[255];
|
|
||||||
uint8_t idx; // numéro de la liaison CDC qui a reçu le message
|
|
||||||
};
|
|
||||||
|
|
||||||
struct message_t messagerie_read_message(const char * chaine, unsigned int * position_chaine);
|
|
||||||
char message_to_string(struct message_t message, char * chaine_texte);
|
|
||||||
uint16_t message_prepare_for_usb(struct message_t message, uint8_t * message_binaire);
|
|
||||||
|
|
||||||
bool message_disponible(void);
|
|
||||||
void put_message(struct message_t message);
|
|
||||||
struct message_t get_message(void);
|
|
||||||
@ -99,10 +99,10 @@
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// Size of buffer to hold descriptors and other data used for enumeration
|
// Size of buffer to hold descriptors and other data used for enumeration
|
||||||
#define CFG_TUH_ENUMERATION_BUFSIZE 256
|
#define CFG_TUH_ENUMERATION_BUFSIZE 512
|
||||||
|
|
||||||
#define CFG_TUH_HUB 1 // number of supported hubs
|
#define CFG_TUH_HUB 1 // number of supported hubs
|
||||||
#define CFG_TUH_CDC 3 // CDC ACM
|
#define CFG_TUH_CDC 1 // CDC ACM
|
||||||
#define CFG_TUH_CDC_FTDI 1 // FTDI Serial. FTDI is not part of CDC class, only to re-use CDC driver API
|
#define CFG_TUH_CDC_FTDI 1 // FTDI Serial. FTDI is not part of CDC class, only to re-use CDC driver API
|
||||||
#define CFG_TUH_CDC_CP210X 1 // CP210x Serial. CP210X is not part of CDC class, only to re-use CDC driver API
|
#define CFG_TUH_CDC_CP210X 1 // CP210x Serial. CP210X is not part of CDC class, only to re-use CDC driver API
|
||||||
#define CFG_TUH_CDC_CH34X 1 // CH340 or CH341 Serial. CH34X is not part of CDC class, only to re-use CDC driver API
|
#define CFG_TUH_CDC_CH34X 1 // CH340 or CH341 Serial. CH34X is not part of CDC class, only to re-use CDC driver API
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user