#include <stdio.h>
#include <stdint.h>
#include "pico/stdlib.h"
void soma_elementos_positivos_um_byte(uint8_t *p_vetor, uint16_t *p_valor_total, uint8_t colunas) {
// Limite: 255 * 255 = 65025 < 65535 (uint16_t)
for (uint8_t i = 0; i < colunas; i++) {
*p_valor_total += *(p_vetor + i);
}
}
void main(void) {
stdio_init_all();
uint8_t vetor[5] = {1, 2, 3, 4, 5};
uint16_t valor_total = 0; // Use 0 em vez de Ø
soma_elementos_positivos_um_byte(vetor, &valor_total, 5); // Ou sizeof(vetor)
printf("Valor total = %u\n", valor_total); // %u para unsigned
}