Skip to content

LabNelson/LLD

 
 

Repository files navigation

Accessing Ethernet with baremetal C on RPi4

The goal of this code is to get the enc28j60 working with CAMeL-View. It will be integrated into a library and used by the CAMeL-View code.

Background

I'm really excited about aquiring knowledge and having a holistic process while doing so. In this process you stumble over simulations, calculations, test plans, testbench-systems, data-analysis and writing scientific papers. Preferably in one tool an of course open source.

The championship of filling the gap between simulations and calculations of scientific approaches combined with real measurements on real hardware and data-analysis. I explored some simulation/testbendch-systems over the years like Matlab, GNU-Octave, LabView, NI myDAQ, MLab, Speedgoat. They are all dealing with software and hardware. Ether the software is expensive or the hardware.

A tool like CAMeL-View can take over a lot of the sub-processes: simulation, calculation, testbench-system (and data-analysis). It prepares the data, being analysed by GNU-Octave and delivers figures to Latex, which is also in my holistic-toolchain. The software is nearly open source but the hardware is not. So let's start making the RPi4 even more powerful.

The GUI of CAMeL-View is written in smalltalk. The IDE from instantiations needs a license, so we can't build the GUI on open source basis yet. The simulation can run on the development machine or on the target machine as well. Therefore CAMeL-View generates c-code which is then compiled and linked against the desired hardware which needs available implementations of the target-drivers. To meet hard real-time requirements FreeRTOS is used as OS. The API to the hardware-code is a C-library. So in writing c-code drivers for the RPi4-peripherals we simultaneously get closer to the CAMeL-View open source hardware.

Preface

This is the SPI-programm forked from LLD (Low Level Devel) extended with the enc28j60 driver from Christian Schoffit, portions from Gregory Nutt. Many thanks to them. The arp-test function is provided by babbleberry.

Setup

I followed the very helpful instructions from babbleberry here to hook up the ENC28J60 to the RPi4's SPI0 interface.

The difference is that we will connect the interrupt line:

Pi pin Pi GPIO Jumper colour ENC28J60 pin
Pin 17 +3V3 power red VCC
Pin 19 GPIO10/MOSI orange SI
Pin 20 GND brown GND
Pin 21 GPIO09/MISO yellow SO
Pin 23 GPIO11/SCLK green SCK
Pin 24 GPIO08/CE0 blue CS
Pin 24 GPIO08/CE0 violett INT

You can find these pins on the gpio-header of the RPi4, here:

GPIO location from RPi-Homepage

Code

To reach the goal the code is splitted into one folder for each step.

The steps are:

  1. getting a network-connection with enc28j60 (enc28j60_arp)
  2. getting connection to CAMeL-dev-machine as the target to the dev-machine and displaying incoming packets (enc28j60_CAMeL-connect)
  3. bitbanging CAMeL-View response of single pendulum-model (enc28j60_CAMeL-bitbang)
  4. integration of code into library (enc28j60_library)

As code is in development not every folder is present.

Disclaimer

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 47.0%
  • C 38.9%
  • Roff 11.7%
  • Python 0.9%
  • XC 0.3%
  • XS 0.3%
  • Other 0.9%