#if(0)
#include "wokwi-api.h"
#include <stdio.h>
#include <stdlib.h>
// prototipi delle funzioni
void wcb_inp(void *u_data, pin_t pin, uint32_t value);
// se commenti la riga sopra ottieni errore
typedef struct {
// TODO: Put your chip variables here
pin_t out;
pin_t inp;
bool on_off;
} chip_state_t;
void chip_init() {
setvbuf(stdout, NULL, _IOLBF, 1024); // Limit output buffering to a single line
chip_state_t *chip = malloc(sizeof(chip_state_t));
printf("Hello from custom chip!\n");
// inizializza il pin INP come ingresso con pull-up
chip->inp = pin_init("INP", INPUT_PULLUP);
// configura winp_cfg (watch inp config)
pin_watch_config_t winp_cfg = {
.edge = FALLING,
.pin_change = wcb_inp,
.user_data = chip
};
// abilita l'osservazione
pin_watch(chip->inp, &winp_cfg);
// pin__^ ^__watch config
}
void wcb_inp(void *u_data, pin_t pin, uint32_t value) {
chip_state_t *chip = (chip_state_t*)u_data;
chip->on_off = !chip->on_off;
if (chip->on_off) {
printf("on\n");
} else {
printf("off\n");
}
}
#endif
void setup() {
}
void loop() {
}