项目作者: gh-BumsooKim

项目描述 :
Deal with Micro-Processor and Micro-Controller such as ARM Architecture included Assembly-Language using Raspberry Pi 4B
高级语言: Assembly
项目地址: git://github.com/gh-BumsooKim/MicroComputerSystem.git
创建时间: 2021-03-03T02:12:03Z
项目社区:https://github.com/gh-BumsooKim/MicroComputerSystem

开源协议:

下载


MicroComputerSystem

중앙대학교 창의ICT공과대학 전자전기공학부 - 마이크로컴퓨터시스템

ARM MircroProcesser Core Assembly Language with Raspi 3




Peripheral Device Control using Linux Kernel System Call with Virtual Memory Mapping

BumSoo Kim*

In 2021 MicroComputerSystem Lecture, CAU (* CAU A&T)

ARM Programming

Environment

  • OS : Raspbian (Raspberry Pi 3)
  • Compiler : gcc (Not Keil)
  • Editor : nano
  • language : ARM Assembly
  1. .data @data area
  2. string: .asciz "Hello world\n"
  3. .text @code area
  4. .global main
  5. main:
  6. push {lr} @push {r14}
  7. ldr r0, =string @parameter
  8. bl printf
  9. pop {pc} @pop {r15}
  10. .end @end

Getting Started

make directory and source file

  1. pwd
  2. mkdir src
  3. nano example.s

assemble source code and run

  1. gcc example.s -o example
  2. ./exmaple

GPIO Programming

Environment

  • OS : Raspbian (Raspberry Pi 3)
  • Compiler : gcc (Not Keil)
  • Editor : nano
  • language : C
  1. #include <stdio.h>
  2. #include <wiringPi.h>
  3. #define LED 18
  4. void main(void){
  5. wiringPiSetupGpio();
  6. pinMode(LED, OUTPUT);
  7. for(;;){
  8. digitalWrite(LED, 1);
  9. delay(500);
  10. digitalWrite(LED, 0);
  11. delay(500);
  12. }
  13. }
  1. gpio -g mode [N] out
  2. gpio -g write [N] 1
  3. gpio -g write [N] 0

Getting Started

(High Level) Peripheral Device Controll with wiringPi

install WiringPi

  1. sudo apt-get install git-core
  2. git clone http://github.com/WiringPi/WiringPi
  3. cd WiringPi
  4. ./build

compile c source code and run

  1. nano example.c
  2. gcc -o example example.c -lwiringPi
  3. ./example

(Low Level) Peripheral Device Controll with mmap

compile custom wiringPi to library file

  1. nano gpmmlib.c
  2. gcc -I./include -c gpmmlib.c
  3. ar r libgpmm.a gpmmlib.o
  4. ranlib libgpmm.a
  5. mkdir lib
  6. mv libgpmm.a ./lib

compile c source with custom library

  1. nano example.c
  2. gcc -I./include -L./lib -o example example.c -lgpmm
  3. sudo ./example