Embedded--arm

Source: Internet
Author: User
Tags strcmp strtok

Two years ago, something, tidy up, maybe later will be used.

Arm for the s3c2440 of this arm-driven finishing.

These include: Adc,beeper buzzer, key key, RTC, timer timer, UART driver.

Project Address (GitHub): https://github.com/yanjinyun/armS3c2440Drive

****************
This is the ADC driver.

#include"s3c2440.h"#if0voidNiuniu (void) {uart_init ();    Adc_init ();    Adc_read ();  while(1) {itoa (Adc_read ()); Delay (10000); }}#endif#ifAdstart==0voidNiuniu (void) {uart_init ();    Adc_init ();    Beeper_init ();    Adc_read ();  while(1) {itoa (Adc_read ()); if(Adc_read () >2500) {beeper_on (); }        Else{Beeper_off (); } Delay (10000); }}#endif#ifAdstart==1voidNiuniu (void) {uart_init ();    Adc_init ();    Beeper_init ();  while(1) {adc_enable ();        Itoa (Adc_read ()); if(Adc_read () >2500) {beeper_on (); }        Else{Beeper_off (); } Delay (10000); }}#endif

********************
Driver for buzzer:

#include"s3c2440.h"#if0voidNiuniu (void) {beeper_init ();  while(1) {beeper_on (); Delay (10000);        Beeper_off (); Delay (10000); }}#endif#if1voidNiuniu (void) {key_init ();    Beeper_init ();  while(1)    {        if(Key_on ( One) ==1) {beeper_on (); }        Else{Beeper_off (); }    }}#endif

***************************
This is the key driver.

#include"s3c2440.h"#if0//key wheel Patrol modevoidNiuniu (void) {led_init ();    Key_init ();  while(1)    {        if(Key_on (5) ==1) {led_on (1); }        Else{Led_off (1); }    }}#endif#if1//Key Interrupt ModevoidNiuniu (void) {beeper_init ();    Key_init ();    Extint_init ();    Int_init ();    Uart_init ();  while(1) {puts ("Key int mode\r\n"); Delay ( +); }}#endif

**************************
This is the LED light driver:

 #include  s3c2440.h   " void  Niuniu (void  ) {Led_init ();  while  (1   2  );        led_on ( 4  );        Delay ( 10000  );        Led_off ( 2  );        Led_off ( 4  );    Delay ( 10000  ); }}

This is the RTC driver.

#include"s3c2440.h"#include<string.h>#include<stdlib.h>#if0voidNiuniu (void){    inttime[7]; Charbuf[ +], *p[9]; inti;        Uart_init ();  while(1) {puts ("\r\nrtc>");        Gets (BUF); Buf[strlen (BUF)-2] =' /'; p[0] = Strtok (buf," ");  for(i=1; p[i-1]!=null; i++) {P[i]= Strtok (NULL," "); }        if(strcmp (p[0],"Timeset") ==0) {time[0] = Atoh (p[1]); time[1] = Atoh (p[2]); time[2] = Atoh (p[3]); time[3] = Atoh (p[4]); time[4] = Atoh (p[5]); time[5] = Atoh (p[6]); time[6] = Atoh (p[7]);        Rtc_init (time); }        if(strcmp (p[0]," Time") ==0) {rtc_display (); }    }}#endif#if1voidNiuniu (void) {uart_init ();    Int_init ();    Alarm_init ();    Beeper_init ();  while(1) {rtc_display (); Sleep (1); }}#endif

This is the driver of the timer:

" s3c2440.h " void Niuniu (void) {    int_init ();    Timer_init ();    Beeper_init ();    Uart_init ();    Timer_update ();      while (1)    {        puts ("haha ... \ r \ n");        Sleep (1);}    }

This is the driver for the UART timer:

#include"s3c2440.h"#include<string.h>#if0voidNiuniu (void){    Charbuf[ +];    Uart_init ();  while(1) {puts ("Send:");        Gets (BUF); Puts ("\NRECV:");    Puts (BUF); }}#endif#if1voidNiuniu (void){    Charbuf[ -]; Char*p[6]; inti;    Beeper_init ();    Led_init ();    Uart_init ();  while(1) {puts ("\r\nuart>");        Gets (BUF); //remove \ r \ nBuf[strlen (BUF)-2] =' /'; //The strtok function uses global variablesp[0] = Strtok (buf," ");  for(i=1; p[i-1]!=null; i++) {P[i]= Strtok (NULL," "); }        if(strcmp (p[0],"LeDon") ==0)        {            if(strcmp (p[1]," All") ==0)            {                 for(i=1; i<5; i++) {led_on (i); }            }            Else            {                 for(i=1; P[i]!=null; i++) {led_on (*p[i]- -); }            }        }        if(strcmp (p[0],"Ledoff") ==0)        {            if(strcmp (p[1]," All") ==0)            {                 for(i=1; i<5; i++) {Led_off (i); }            }            Else            {                 for(i=1; P[i]!=null; i++) {Led_off (*p[i]- -); }            }        }        if(strcmp (p[0],"Beeperon") ==0) {beeper_on (); }        if(strcmp (p[0],"Beeperoff") ==0) {Beeper_off (); }    }}#endif

Embedded--arm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.