Can I use the SPRESENSE SDK with Arduino IDE?

Asked 2 years ago, Updated 2 years ago, 115 views

I remember that there was a story about using the SPRESENSE SDK that could be used on Arduino IDE, but I don't have the impression that I can do it with the materials I've been reading for a long time, but is it really possible?

1.5.Verifying Operation on Serial Terminals (Spresense SDK Tutorial)

spresense arduino

2022-09-29 21:41

1 Answers

As we are discussing how to handle the question, do you mean "ArduinoIDE can access the SDK API?", so the answer is "can you do".

In my Windows 10 environment, I have the source code in the "SPRESENSE" folder in "My Documents\Arduino Data", but if you look at it, you can see that the SPRESENSE's library for Arduino is based on the SDK's API.

As a trial, I compiled the following code on Arduino IDE with reference to the SDK sample, but it somehow worked (when I applied voltage to A0, the value changed like that).

For your information.

#include<sys/ioctl.h>
# include <stdio.h>
# include <fcntl.h>   
# include<arch/chip/cxd56_scu.h>
# include <arch/chip/cxd56_adc.h>

int fd;
intret;
void setup() {
  fd = open("/dev/lpadc0", O_RDONLY);
  if(fd<0){
      printf("open/dev/lpadc0failed\n");
      return;
  }
  ret = ioctl(fd, SCUIOC_SETFIFOMODE, 1);
  if(ret<0){
      printf("ioctl(SETFIFOMODE) failed\n");
      return;
  }
  ret = ioctl(fd,ANIOC_CXD56_START,0);
  if(ret<0){
      printf("ioctl(START)failed\n");
      return;
  }  
}

#define BUFSIZE16
char buf [BUFSIZE];
void loop() {
  delay(1000);
  ssize_tnbytes=read(fd, buf, BUFSIZE);
  if(nbytes<=0){
      printf("read failed or zero\n");
      return;
  }
  for(inti=0;i<BUFSIZE;i+=2){
    int n = i/2;
    uint16_t data=buf[i]<8|buf[i+1];// big endian?little endian?
    printf("data[%d]:%d\n", n, data);
  }
}


2022-09-29 21:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.