RP20240_Device_USB/main.c

80 lines
1.6 KiB
C

/*****
* Copyright (c) 2023 - Poivron Robotique
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "pico/stdlib.h"
#include <stdio.h>
void stdio_usb_out_chars(const char *buf, int length);
#define NB_MORCEAUX 100
absolute_time_t envoie_nb_char(int nb_char);
char message[10000];
void envoie_donnees(char * donnees, u_int16_t length){
for (int i=0; i<length; i++){
putchar(donnees[i]);
}
}
void main(void)
{
absolute_time_t measured_time_us;
absolute_time_t temps_moyen, temps_max, temps_m[NB_MORCEAUX];
absolute_time_t current_time_us, start_time_us;
for(int i=0; i<10000; i++){
/*j++;
if(j>25){
j=0;
}
message[i]= j + 'a';*/
message[i]= i%26 + 'a';
}
int nb_ech = 10;
int taille_morceau = 60;
stdio_init_all();
while(1){
temps_moyen = 0;
temps_max = 0;
for(int i = 1; i < NB_MORCEAUX; i++){
temps_moyen = 0;
temps_max = 0;
start_time_us = get_absolute_time();
temps_m[i] = envoie_nb_char(taille_morceau);
//temps_m[i] = i;
current_time_us = get_absolute_time();
sleep_ms(1);
}
for(int i = 1; i < NB_MORCEAUX; i++){
printf(">temps:%d:%lld#us\n", i, temps_m[i]);
}
printf(">temps_d:%lld\n", current_time_us - start_time_us);
sleep_ms(50);
}
}
absolute_time_t envoie_nb_char(int nb_char) {
absolute_time_t current_time_us, start_time_us;
int j=0;
if (nb_char == 0){
return 0;
}
message[nb_char - 1] = '\n';
message[nb_char] = '\0';
start_time_us = get_absolute_time();
printf("%s", message);
envoie_donnees(message, strlen(message));
current_time_us = get_absolute_time();
message[nb_char - 1] = 'a';
message[nb_char] = 'a';
return current_time_us - start_time_us;
}