Other Projects

Lazarus (free pascal) The underlying class library [Baidu.com translate]

1 3453
tjCFeng  

Some of the packaging of full Chi A20 processor underlying operations, using Free Pascal, encapsulation class.

Method of use: add folder path which can place in engineering.


General every peripheral functions, divided into two parts package, one is directly to a Pin or channel operations, the realization of common function package; another is for the type of peripheral register operations, used on the formerno package to function set.


At present, the realization of the GPIO, LRADC, PWM package, follow-up function completed, and is trying to interruptresponse function increase.


The classes available in the console, there is no interface or may interface procedures, and according to the differentcompiler, can also be used in different operating system, only few code changes, such as references of different unitetc..


All records in other series processor can also use this class, such as A10, only need to change according to the difference part, or re implementation inheritance.


Author: tjCFeng

E-mail: tjCFeng@163.com


Example:


1.TGPIOGROUP
var PHG: TGPIOGROUP;
begin
  PHG:= TGPIOGROUP.Create(PH); //创建
  PHG.GPIO_DAT^:= PHG.GPIO_DAT^ or ($1 shl 24); //设置寄存器的值
  PHG.Free; //释放
end;

2.TGPIO
begin
  with TGPIO.Create(PH, 24) do
  begin
    Fun:= Fun1; //设置PH24为输出
    Data:= True; //设置高电平
    Sleep(1000);
    Reverse; //反转电平
    Free; //释放
  end;
end;

var PH24: TGPIO;
begin
  PH24:= TGPIO.Create(PH, 24);
        PH24.Fun:= Fun1;
        PH24.Reverse;
        PH24.Free;
end;

3.LRADC
var ADC0: TLRADC; Data: Byte;
begin
  ADC0:= TLRADC.Create(LRADC_0); //创建LRADC通道0
  TLRADCGROUP.Instance.ClearAllPending; //清除所有未决中断,单例中的功能
  ADC0.INTs:= [ADCDATA, KEYDOWN, KEYUP]; //设置需要响应的中断类型
  TLRADCGROUP.Instance.Start; //开启LRADC,单例中的功能
  Data:= ADC0.Data; //获取LRADC通道0的值0~64
  TLRADCGROUP.Instance.Stop; //停止LRADC,单例中的功能
  ADC0.Free; //释放
end;

4.PWM
var PWM1: TPWM;
begin
  PWM1:= TPWM.Create(PWM_1); //创建PWM通道1
  with PWM1 do
  begin
    Prescale:= P960; //设置预分频
    Cycle:= 6000; //设置周期计数
    Duty:= 1000;  //设置占空比计数
    Start; //开始PWM输出
    Sleep(3000);
    Stop; //停止PWM输出
    Free; //释放
  end;
end;


Version history:


2014.10.03 V0.1 complete package GPIO , LRADC, PWM class.


ClassA20.zip (7.31 KB, Downloads: 21)

Good! Although I don't know what is this for...

You have to log in before you can reply Login | Sign Up

Points Rules