[IO]IPC GPIO control example

Jeongkyu(Jun)·2022년 11월 30일
0

Embedded

목록 보기
1/2

IPC: NEXCOM NISE3500

with oscilloscope

#include <sys/io.h>
//#include <asm/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#define GPIO_PORT   0x3E4
#define GPO3       (0x01 << 4)
#define GPO5       (0x01 << 5)
#define GPO7       (0x01 << 6)
#define GPO9       (0x01 << 7)

#define GPO3_HI    outb(0x10, GPIO_PORT)
#define GPO3_LO    outb(0x00, GPIO_PORT)
#define GPO5_HI    outb(0x20, GPIO_PORT)
#define GPO5_LO    outb(0x00, GPIO_PORT)
#define GPO7_HI    outb(0x40, GPIO_PORT)
#define GPO7_LO    outb(0x00, GPIO_PORT)
#define GPO9_HI    outb(0x80, GPIO_PORT)
#define GPO9_LO    outb(0x00, GPIO_PORT)

int main(){
    /* Get access to the ports. */
    if (iopl(3) == -1) {
        printf("errno: %d", errno);
        exit(1);
    }
    // outb/inb stuff
    unsigned int cnt = 5;
    while (cnt) {
        GPO7_HI;
        GPO9_HI;
        usleep(1000000);
        outb(0x00, GPIO_PORT);
        cnt --;
        usleep(1000000);
    }
       
    /* Close the ports. */
    if (iopl(0) == -1) {
        printf("errno: %d", errno);
        exit(1);
    }
    printf("done");
}
profile
안녕하세요

0개의 댓글