// #include <stdio.h>
// #include "pico/stdlib.h"
#include "hardware/gpio.h"

// Must declare the main assembly entry point before use.
void main_asm();

// void asm_hw() {
//   printf("Hello, world!\n");
// }


// void asm_printf(int n) {
//   printf("%i\n", n);
// }


/**
 * @brief Wrapper to allow the assembly code to call the gpio_init()
 *        SDK function.
 * 
 * @param pin       The GPIO pin number to initialise.
 */
void asm_gpio_init(int pin) {
    gpio_init(pin);
}


/**
 * @brief Wrapper to allow the assembly code to call the gpio_set_dir()
 *        SDK function.
 * 
 * @param pin       The GPIO pin number of which to set the direction.
 * @param dir       Specify the direction that the pin should be set to (0=input/1=output).
 */
void asm_gpio_set_dir(int pin, int dir) {
    gpio_set_dir(pin, dir);
}


/**
 * @brief Wrapper to allow the assembly code to call the gpio_get()
 *        SDK function.
 * 
 * @param pin       The GPIO pin number to read from.
 * @return int      Returns the current value of the GPIO pin.
 */
int asm_gpio_get(int pin) {
    return gpio_get(pin);
}


/**
 * @brief Wrapper to allow the assembly code to call the gpio_put()
 *        SDK function.
 * 
 * @param pin       The GPIO pin number to write to.
 * @param value     Specify the value that the pin should be set to (0/1).
 */
void asm_gpio_put(int pin, int value) {
    gpio_put(pin, value);
}


/**
 * @brief EXAMPLE - BLINK_ASM
 *        Simple example that uses assembly code to initialise
 *        the built-in LED on Raspberry Pi Pico and then flash
 *        it forever using a sleep routine to set the period of
 *        the flash.
 * 
 * @return int      Returns exit-status zero on completion.
 */
int main() {

    // Jump into the main assembly code subroutine.
    main_asm();
    
    // // printf("here\n");
    // gpio_init(25);
    // gpio_init(21);
    // gpio_set_dir(25, 1);
    // gpio_set_dir(21, 0);

    // while (true) {
    //   gpio_put(25, 1);
    //   sleep_ms(500);
    //   gpio_put(25, 0);
    //   sleep_ms(500);
    // }

    // while (1) {
    //   // printf("waiting\n");
    //   // if button is pressed
    //   // printf("wating\n");
    //   int on = gpio_get(21);
    //   // printf("%d\n", on);
    //   if (gpio_get(21) == 1) {
    //     // printf("it worked\n");
    //     break;
    //     // printf("its onnnn\n");
    //     // toggle light
    //     // if light is on

    //     // if (gpio_get(25) == 1) {
    //     //   // turn it off
    //     //   gpio_put(25, 0);
    //     // }
    //     // else { // if light in off
    //     //   // turn it on
    //     //   gpio_put(25, 1);
    //     // }
    //   }
    //   sleep_ms(250);

    // }


    // Returning zero indicates everything went okay.
    return 0;
}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT