18

A new RISC-V version of uLisp

 4 years ago
source link: http://www.ulisp.com/show?30X8=
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Sipeed Maixduino RISC-V board

A new RISC-V version of uLisp is designed to support microcontroller boards based on the RISC-V processor.

RISC-V is a free, open RISC Instruction Set Architecture that began development in 2010 at the University of California, Berkeley. A range of boards has been developed by Sipeed based on the K210, a RISC-V chip manufactured by Canaan Inc. of Beijing, China.

The first RISC-V board supported by uLisp is the Sipeed Maixduino . The RISC-V version of uLisp includes graphics extensions, to allow you to plot points, lines, shapes, and text to the Maixduino colour TFT display. It also includes a RISC-V assembler that allows you to generate machine-code functions, integrated with Lisp, written in RISC-V code. The assembler itself is written in Lisp to make it easy to extend it or add new instructions.

RISC-V assembler

For an overview of the RISC-V assembler and details of how to install it see: RISC-V assembler overview .

For a summary of the instructions in the RISC-V assembler see: RISC-V assembler instructions .

For example programs see: RISC-V assembler examples .

Sipeed Maixduino

BZ3eqiu.jpg!web

The Sipeed Maixduino is an Arduino Uno form factor board based on a Kendryte K210 RISC-V Dual Core 64 bit 400 MHz processor with Neural Network Processor (KPU) and Floating-Point Processor (FPU). It includes 8 Mbytes RAM, 16 Mbytes flash, a Micro SD card slot, and a LCD interface, making it an ideal platform for running uLisp.

Additional peripherals, some of which are not yet fully supported, include an ESP32 module to offer 2.4 GHz WiFi and Bluetooth 4.2, a MEMS microphone, a DVP camera, and an I2S audio output driving a 3W audio amplifier.

It's available with or without a compatible 320x240 Colour LCD display from Seeedor Unmanned Tech in the UK.

Setting up the Sipeed Maixduino

The Maixduino board is fitted with a USB-C socket. If your computer only has USB-A then you can use it with a USB-C cableand USB-C Female to Type A USB 3.0 Male Adapter.

You can install the RISC-V version of uLisp on a Sipeed Maixduino using the Arduino IDE as follows:

  • Download the RISC-V version of uLisp from the downloads page: Download uLisp.
  • Open the Boards Manager…  from the Board  item on the Tools menu, search for  Maixduino , and install Maixduino (K210) by Sipeed .
  • Connect the Maixduino board to your computer using a USB cable.
  • Select Sipeed Maixduino Board from the Maixduino section on the  Board menu.
  • Set Port to /dev/cu.usbserial-495223D74D0  or similar.
  • Set Programmer to k-flash .

You can leave the other options at their defaults.

Updating the Arduino core

There is one change I recommend you make to the Maixduino Arduino core before uploading uLisp; without this change the Serial Monitor drops characters if you paste more than a few lines into the input field:

  • Locate the file:
David/Library/Arduino15/packages/Maixduino/hardware/k210/0.3.11/cores/arduino/RingBuffer.h

replacing David by the name of your user folder, and 0.3.11 by the version of Maixduino you have installed.

  • Edit the file in a text editor, and change the line:
#define RING_BUFFER_SIZE 64

to:

#define RING_BUFFER_SIZE 1024

Installing uLisp

You should now be able to upload uLisp to the Maixduino.

Follow the instructions inUsing uLispto interact with uLisp on the Maixduino.

Pin connections

JfYrmu3.png!web

Digital inputs and outputs

The Maixduino provides 13 digital inputs or outputs accessible on the headers labelled 0 to 13. Each of these can be configured as an output, or an input with an optional pullup or pulldown. Note that unlike on Arduino boards, a pin won't operate as an input until pinmode has been called.

Analogue outputs

Any of the I/O pins can also be used as a PWM analogue output, using analogwrite with a value between 0 and 255.

Analogue inputs

The Maixduino Arduino core hasn't yet implemented the analogue inputs.

TFT display

The Maixduino board provides a connector for a 320x240 Colour LCD TFT display:

NNVJziF.jpg!web

For information about the graphics extensions in RISC-V uLisp seeGraphics extensions.

The following program draws the above colour demo display:

(defun rgb (r g b)
  (logior (ash (logand r #xf8) 8) (ash (logand g #xfc) 3) (ash b -3)))

(defun plot ()
  (dotimes (xx 320)
    (let ((x (- xx 160)))
      (dotimes (yy 240)
        (let* ((y (- yy 120))
               (f (truncate (+ (* x (+ x y)) (* y y)) 8)))
          (draw-pixel xx yy (rgb (+ f 160) f (+ f 80))))))))
  1. Sipeed Maixduino for RISC-V AI + IoT on Seeed.
  2. Sipeed Maixduino RISC-V Development Board on Unmanned Tech.
  3. Apple USB-C Charge Cable on Amazon.
  4. USB-C Female to Type A USB 3.0 Male Adapter on Amazon.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK