Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arduino framework support discussion #155

Open
RodrigoDornelles opened this issue Jul 7, 2021 · 6 comments
Open

arduino framework support discussion #155

RodrigoDornelles opened this issue Jul 7, 2021 · 6 comments

Comments

@RodrigoDornelles
Copy link
Owner

RodrigoDornelles commented Jul 7, 2021

I'm bringing the discussion about supporting the arduino framework.

my initial idea is to have a memory configuration, which behaves like GPIO, so if you want to have better names than their numbers port, you can work with pointers.

Blink Example

equivalent in C

const int LED = 1;

setup() {
    pinMode(LED, OUTPUT);
}

loop() {
    sleep(1000);
    digitalWrite(!digitalRead(LED));
}

proposed in 3BC

# SETUP
MODE    NILL    0d06
TCNF    0x01    DOUT # Type config digital output
ALOC    "LED"   0x01 # Led set address of gpio 1 

# LOOP
MODE    NILL    ???? # some future mode for wait
NILL    NILL    "BLINK_FUNFC"
????    NILL    1 # some register to sleep for 1 seconds
MODE    NILLL   0d07
PULL    "LED"   NILL
MODE    NILL    0d08
ZGTO    NILL    "TURN_ON"

# LIGHT OFF LED
MODE    NILL    0d07
ALOC    "LED"   0    # write 0 in LED pointer
MODE    NILL    0d08
GOTO    NILL    "BLINK_FUNFC"

# LIGHT ON LED
MODE    NILL    0d07
NILL    NILL    "TURN_ON" 
ALOC    "LED"   1    # write 1 in LED pointer
MODE    NILL    0d08
GOTO    NILL    "BLINK_FUNFC"
@RodrigoDornelles RodrigoDornelles pinned this issue Jul 7, 2021
@Lrv-dev
Copy link
Contributor

Lrv-dev commented Jul 7, 2021

cool

@mateustoin
Copy link

Sounds like microcontrollers in University all over again. It's very cool doing things using a low level of abstraction.

@kadu
Copy link
Contributor

kadu commented Jul 8, 2021

The implementation was very nice, You would continue with this implementation! ;)!

@RodrigoDornelles
Copy link
Owner Author

RodrigoDornelles commented Jul 17, 2021

for internal development, I came up with the idea of these memory modifications.

#define MEM_CONFIG_RESERVED         (0b00000001) /** unused for a while **/
#define MEM_CONFIG_MAX_VALUE        (0b00000010) /** exists maximum value **/
#define MEM_CONFIG_MIN_VALUE        (0b00000100) /** exists minimum value **/
#define MEM_CONFIG_NORMALIZE        (0b00001000) /** transform clamp to map **/
#define MEM_CONFIG_GPIO_SEND        (0b00010000) /** digital output **/
#define MEM_CONFIG_GPIO_READ        (0b00100000) /** digital input **/
#define MEM_CONFIG_GPIO_PULL        (0b01000000) /** pullup input **/
#define MEM_CONFIG_GPIO_ANAL        (0b10000000) /** analogic/pwd **/

reflection

  • to use MEM_CONFIG_GPIO_ANAL you must use it together with MEM_CONFIG_GPIO_READ or MEM_CONFIG_GPIO_SEND

  • using MEM_CONFIG_GPIO_PULL with MEM_CONFIG_GPIO_ANAL will cause an error

  • using MEM_CONFIG_GPIO_PULL with MEM_CONFIG_GPIO_SEND will cause an error

  • using MEM_CONFIG_GPIO_ANAL or MEM_CONFIG_GPIO_PULL alone (whitout MEM_CONFIG_GPIO_READ or MEM_CONFIG_GPIO_SEND) will cause an error

@RodrigoDornelles
Copy link
Owner Author

RodrigoDornelles commented Jul 18, 2021

now fully supports GPIO 9e27da1, this was the first test turning on lights from an LED bulltin.

#include <3bc.h>

void setup() {
  lang_driver_init();
  lang_line(MODE, NILL, 6);
  lang_line(MUSE, 13, MEM_CONFIG_GPIO_SEND);
  lang_line(ALOC, 13, HIGH);
  lang_driver_run();
  lang_driver_exit();
}

void loop() {}
  • NOTE the mcfg register (old tcfg) no longer exists, using the improved one instead of muse 63a6177.

@RodrigoDornelles
Copy link
Owner Author

implemented in 8d710c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants