极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 23471|回复: 18

LGT8F690A LGTSDK_Builder_1.5 API 初探

[复制链接]
发表于 2019-1-30 09:36:24 | 显示全部楼层 |阅读模式
本帖最后由 eddiewwm 于 2019-1-30 10:26 编辑

LGT8F690A SDK API:
A)        System and Power
B)        I/O Subsystem
C)        External Interrupt
D)        USART Module
E)        SPI Module
F)        I2C Module
G)        WatchDog Timer
H)        Timer/Counter 0
I)        Timer/Counter 1
J)        Timer/Counter 2
K)        EEPROM Module
L)        ADC Module
M)        DAP Module
N)        DAC Module
O)        Analog Comparator
P)        Miscellany

資源來自:【http://www.lgtic.com/downloads/    辅助开发工具    LGTSDK_Builder_1.5beta30】
回复

使用道具 举报

 楼主| 发表于 2019-1-30 09:37:05 | 显示全部楼层
本帖最后由 eddiewwm 于 2019-1-30 09:39 编辑

A) System and Power
系统上电后,MCUCR 寄存器从配置位中加载指令周期模式TCYC 配置。此后,软件可以随时通过MCUCR寄存器的TCYC 位更新。
由于MCUCR 寄存器控制了关键的内核运行模式,因此MCUCR 寄存器有保护设计,更新MCUCR 寄存器需要严格按照一个预定的时序:首先向MCUCR 地址写数据0x55,然后紧接着写入要更新的数据。
1)        Set core cycle:  void sysCoreCycle(ccyc)
Where: macro ccyc is instruction cycle settings:
SYS_TCYC_1T: SET CORE CYCLE TO 1T MODE,
SYS_TCYC_2T: SET CORE CYCLE TO 2T MODE,
SYS_TCYC_4T: SET CORE CYCLE TO 4T MODE,
e.g.: sysCoreCycle(SYS_TCYC_4T)

2)        Bring system to sleep with current Sleep mode:        void sysSleep()
e.g. sysSleep()

3)        Bring system to sleep with given mode:                void sysSleepByMode(u8 mode)
Where: u8 mode is power mode settings:
SYS_SLEEP_IDLE: idle mode, disable core clock only,
SYS_SLEEP_SAVE: save mode, RC32k keep running
SYS_SLEEP_DEEP: deep mode, disable all clocks
e.g. sysSleepByMode(SYS_SLEEP_DEEP)

4)        Set system clock to internal INTRC:                void sysClockINTRC(u8 mode)
Where: u8 mode is select internal clock source
SYS_INTRC_DIV0: 16MHz HFINTOSC without scaler
SYS_INTRC_DIV2: 16MHz HFINTOSC divided by 2
SYS_INTRC_DIV4: 16MHz HFINTOSC divided by 4
SYS_INTRC_DIV8: 16MHz HFINTOSC divided by 8
SYS_INTRC_DIV16: 16MHz HFINTOSC divided by 16
SYS_INTRC_DIV32: 16MHz HFINTOSC divided by 32
SYS_INTRC_DIV64: 16MHz HFINTOSC divided by 64
SYS_INTRC_RC32K: 32kHz LFINTOSC
e.g. sysClockINTRC(SYS_INTRC_DIV64)

5)        Restore system clock setting to default:                void sysClockRestore()
e.g. sysClockRestore()

6)        Set system power level according to instruction cycle to save power consumption: void sysPowerLevel(u8 level)
Where: u8 level is the select system power level:
SYS_POWER_HL: high level power mode for 8MHz~20MHz instruction cycle
SYS_POWER_ML: middle level power mode for 500kHz~8MHz instruction cycle
SYS_POWER_LL: low level power mode for 500kHz instruction cycle
e.g. sysPowerLevel(SYS_POWER_HL)

7)        Global pullup enable:        void sysPullupEnable()
8)        Global pullup disable:        void sysPullupDisable()
9)        Enable System clock output on RA3:        void clkoEnable()
10)        Disable System clock output on RA3:        void clkoDisable()
11)        Enable low voltage reset (LVR) module:        void lvrEnable()
12)        Disable low voltage reset (LVR) module:        void lvrDisable()
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:41:56 | 显示全部楼层
B) I/O Subsystem
Note: in following:
macro gpp: port group name, can be GPPA, GPPB or GPPC
macro pn: pin name, can be P7, P6, …., P0

1)        Set port as output:        void gppOutputEnable(gpp, pn)
e.g. gppOutputEnable(GPPA, P7|P2|P1)

2)        Set port as input:                void gppOutputDisable(gpp, pn)
e.g. gppOutputDisable(GPPA, P7|P2|P1)

3)        Read port status:                void gppRead(gpp)
e.g. gppRead(GPPA)

4)        Read status of a single pin:                u8 gppReadSingle(gpp, pn)
Return:        u8 pin status, return 0 or 1
e.g. gppReadSingle(GPPA, P7)

5)        Drive port to high:        void gppHigh(gpp, pn)
e.g. gppHigh(GPPA, P7|P2|P1)

6)        Drive port to low:        void gppLow(gpp, pn)
e.g. gppLow(GPPA, P7|P2|P1)

7)        Toggle port’s output status:        void gppToggle(gpp, pn)
e.g. gppToggle(GPPA, P7|P2|P1)

8)        Global pullup enable for RA/RB:                void sysPullupEnable()
9)        Global pullup disable for RA/RB:                void sysPullupDisable()
10)        Enable pin’s internal pullup:        void gppPullupEnable(gpp, pn)
e.g. gppPullupEnable(GPPA, P7|P2|P1)

11)        Disable pin’s internal pullup:        void gppPullupDisable(gpp, pn)
e.g. gppPullupDisable(GPPA, P7|P2|P1)

12)        Enable pin’s internal pulldown:        void gppPulldownEnable(gpp, pn)
e.g. gppPulldownEnable(GPPA, P7|P2|P1)

13)        Disable pin’s internal pulldown:        void gppPulldownDisable(gpp, pn)
e.g. gppPulldownDisable(GPPA, P7|P2|P1)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:43:06 | 显示全部楼层
C) External Interrupt
Note: in following:
macro port: port group name, can be GPPA or GPPB
macro pn: pin name, can be P7, P6, …., P0, PALL

1)        Disable external interrupt:                void eintDisable()
2)        Enable external interrupt:                void eintEnable()
3)        Enable pin level change Interrupt:        void eintEnableIOC(port, pn)
e.g. eintEnableIOC(GPPB, P2)

4)        Disable pin level change interrupt:        void eintDisableIOC(port, pn)
e.g. eintDisableIOC(GPPB, P2)

5)        Test if level change interrupt flag is set or not:        void eintTestIOCF(port, pn)
e.g. if(eintTestIOCF(GPPB, P2))        {……..}

6)        Clear level change interrupt flag caused by RB0:        void eintClearIOCF(port, pn)
e.g. eintClearIOCF(GPPB, P0)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:44:17 | 显示全部楼层
D) USART Module
1)        Transmit a byte data to USART interface:        void usartPutChar(char u8char)
Where: char u8char: Byte to transmit
e.g. usartPutChar(0x68)        (There is also an alias, named usartWriteByte())

2)        Receive a byte data from USART interface:        char usartGetChar(void)
Return: char: Byte received from USART interface
e.g. ReceiveChar = usartGetChar()        (There is also an alias, named usartReadByte())

3)        Asynchronous version of usartGetChar():        void usartGetCharAsync(char *rxd)
Where: char *rxd  is a byte address for received data
Return: char: 0=no data coming, 1=data received
e.g. usartGetCharAsync(rxPointer)        (There is also an alias, named usartReadByteAsync())

4)        Transmit string buffer to USART interface:                void usartPutStr(char *str)
Where: char *str                is strng to transmit
e.g. usartPutStr(strPointer)                        (There is also an alias, named usartWriteString())
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:52:45 | 显示全部楼层
E) SPI Module
1)        Set [SPSS] pin to high level, used for SPI master mode to deselect a slave:        void spiSPSSOFF()
2)        Set [SPSS] pin to low level used for SPI master mode to select a slave:                void spiSPSSON()
3)        Exchange a byte between SPI master and slave:        u8 spTransferByte(u8 data)
Where: u8 data:  is data for serial out
Return: u8:        return 8-bit data serial n
e.g. spiRxData = spTransferByte(0x68)

4)        Read length of bytes from SPI bus:        void spiReadBuffer(u8 *rxbuf, u8 length)
Where:        u8 *rxbuf:  data buffer for data in
                        U8 length:  determine the length of transfer
e.g. spiReadBuffer(rxbufPointer, 0x0F)

5)        Write length of bytes to SPI Bus:        void spiWrteBuffer(u8 *txbuf, u8 length)
Where:        u8 *txbuf:  data buffer for data out
                        U8 length:  determine the length of transfer
e.g. spiWriteBuffer(txbufPointer, 0x0F)

6)        Exchange length of bytes between SPI master and slave: void spiTransferBuffer(u8 *txbuf, u8 *rxbuf, u8 length)
Where:         u8 *txbuf:  data buffer for data out
                        u8 *rxbuf:  data buffer for data in
                        U8 length:  determine the length of transfer
e.g. spiTransferBuffer(txbufPointer, rxbufPointer, 0x0F)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:54:39 | 显示全部楼层
F) I2C Module
1)        Set I2C device address:        void i2cSetDevAddress(u8 devAddr)
Where: u8 devAddr:        7-bit device address
e.g. i2cSetDevAddress(0x3C)

2)        Begin apply for I2C Master:                void i2CBeginTransmission(u8 trType)
Where: u8 trType:        Read/Write mode for transmission
                                        I2C_READ: begin bus read transmission
                                        I2C_WRITE: begin bus write transmission
e.g. i2CBeginTransmission(I2C_READ)

3)        Begin for I2C Slave:        void i2cBeginTransmission()

4)        Disable I2C transmission and I2C module:                void i2cEndTransmission()

5)        As a master to read data:        char i2cReadByte()
Return: char:        data read from bus
e.g. readData = i2cReadByte()

6)        As a master to write data:        char i2cWriteByte(u8 data)
Where: u8 data:                data will send to I2C bus
Return: char:        return bus acknowledge, I2C_NAK or I2C_ACK
e.g. ackSignal = i2cWriteByte(0x86)

7)        Send length of data to i2c bus:        char i2cWriteBuffer(char *txbuf, u8 length)
Where:         char *txbuf:        data buffer will send to I2C bus
                        U8 length:        data length will send to I2C bus
Return:        char:        return I2C_FAIL or I2C_SUCCESS
e.g. returnResult = i2cWriteBuffer(txbufPointer, 0x0F)

8)        Read length of data from I2C bus:        void i2cReadBuffer(char *rxbuf, u8 length)
Where:         char *rxbuf:                data buffer to store data read from I2C bus
                        U8 length:        data length to read from I2C bus
e.g. i2cReadBuffer(rxbufPointer, 0x0F)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:55:37 | 显示全部楼层
G) WatchDog Timer
1)        Start WDT module:        void wdtStart()
2)        Disable WDT module:                void wdtStop()
3)        Reset WDT, or feed the dog:        void wdtReset()
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:56:45 | 显示全部楼层
H) Timer/Counter 0
1)        Stop timer0:        void tc0Stop()
2)        Start timer0, use to restart timer if it is stopped by tc0Stop():        void tc0Start()
3)        Reload counter register of TMR0:        void tc0Reload(u8 value)
e.g. tc0Reload(0x45)
4)        Enable overflow interrupt of TMR0:        void tc0InterruptEnable()
5)        Disable overflow interrupt of TMR0:        void tc0InterruptDisable()
6)        TMR0 overflow interrupt of TMR0:        u8 tc0InterruptFlag()
Return:        0=interrupt not enabled or not happen
                        1=overflow interrupt is valid
e.g. T0Flag = tc0InterruptFlag()
7)        Clear interrupt flag of TMR0:        void tc0InterruptClear()
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:59:46 | 显示全部楼层
I) Timer/Counter 1
1)        Stop timer1:        void tc1Stop()
2)        Start timer1, use to restart timer if it is stopped by tc1Stop():        void tc1Start()
3)        Enable T1C1/PWM output:                void t1c1OutputEnable()
4)        Disable T1C1/PWM output:        void t1c1OutputDisable()
5)        Enable T1C2/PWM output:                void t1c2OutputEnable()
6)        Disable T1C2/PWM output:        void t1c2OutputDisable()
7)        Enable T1C3/PWM output:                void t1c3OutputEnable()
8)        Disable T1C3/PWM output:        void t1c3OutputDisable()
9)        Set period register PR1 of TMR1:        void tc1SetPR1(u16 value)
10)                                                                         void tc1SetPeriod(u16 value)
11)        Set duty ratio register T1C1:        void t1c1SetDuty(u16 value)
12)        Set duty ratio register T1C2:        void t1c2SetDuty(u16 value)
13)        Set duty ratio register T1C3:        void t1c3SetDuty(u16 value)
14)        Get capture register of T1C1:        u16 t1c1GetCapture()
15)        Get capture register of T1C2:        u16 t1c2GetCapture()
16)        Get capture register of T1C3:        u16 t1c3GetCapture()
17)        Enable TMR1 overflow interrupt:        void tc1InterruptEnable()
18)        Disable TMR1 overflow interrupt:        void tc1InterruptDisable()
19)        Get TMR1 overflow interrupt status:                u8 tc1InterruptFlag()
20)        Clear TMR1 overflow interrupt status:        void tc1InterrutClear()
21)        Enable ECP1 interrupt:        u8 ecp1InterruptEnable()
22)        Disable ECP1 interrupt:        u8 ecp1InterruptDisable()
23)        Get ECP1 interrupt status:        u8 ecp1InterruptFlag()
24)        To check if ECP1 interrupt caused by T1C1 channel:        u8 t1c1InterruptFlag()
25)        To check if ECP1 interrupt caused by T1C2 channel: u8 t1c2InterruptFlag()
26)        To check if ECP1 interrupt caused by T1C3 channel: u8 t1c3InterruptFlag()
27)        Clear ECP1 interrupt status include ECP1_IF1/2/3:        void ecp1InterruptClear()
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 10:13:39 | 显示全部楼层
J) Timer/Counter 2
1)        Stop timer2:        void tc2Stop()
2)        Start timer2, use to restart timer if it is stopped by tc2Stop():        void tc2Start()
3)        Enable T2C1 output:                void t2c1OutputEnable()
4)        Disable T2C1 output:        void t2c1OutputDisable()
5)        Enable T2C2 output:                void t2c2OutputEnable()
6)        Disable T2C2 output:        void t2c2OutputDisable()
7)        Enable T2C3 output:                void t2c3OutputEnable()
8)        Disable T2C3 output:        void t2c3OutputDisable()
9)        Enable T2C4 output:                void t2c4OutputEnable()
10)        Disable T2C4 output:        void t2c4OutputDisable()
11)        Enable T2C1N output:                void t2c1nOutputEnable()
12)        Disable T2C1N output:        void t2c1nOutputDisable()
13)        Enable T2C2N output:                void t2c2nOutputEnable()
14)        Disable T2C2N output:        void t2c2nOutputDisable()
15)        Enable T2C3N output:                void t2c3nOutputEnable()
16)        Disable T2C3N output:        void t2c3nOutputDisable()
17)        Set period register PR2 of TMR2:        void tc2SetPR2(u16 value)
18)        Set duty ratio register T2C1:        void t2c1SetDuty(u16 value)
19)        Set duty ratio register T2C2:        void t2c2SetDuty(u16 value)
20)        Set duty ratio register T2C3:        void t2c3SetDuty(u16 value)
21)        Set duty ratio register T2C4:        void t2c4SetDuty(u16 value)
22)        Get capture register of T2C1:        u16 t2c1GetCapture()
23)        Get capture register of T2C2:        u16 t2c2GetCapture()
24)        Get capture register of T2C3:        u16 t2c3GetCapture()
25)        Get capture register of T2C4:        u16 t2c4GetCapture()
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 10:14:20 | 显示全部楼层
K) EEPROM Module
1)        Write data to address of EEPROM:        void eepWrite(u8 address, u8 data)
2)        Return a byte from address of EEPROM:        void eepRead(u8 address)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 10:15:33 | 显示全部楼层
L) ADC Module
1)        Enable ADC module:                void adcEnable()
2)        Disable ADC module:        void adcDisable()
3)        Set reference voltage for ADC:        void adcSetReference(u8 refs)
Where: u8 refs:        set voltage reference source of ADC
                                ADC_REFS_AVREF:        reference from external AVREF/RA7
                                ADC_REFS_AVCC:        reference from power supply
                                ADC_REFS_1D50:        reference from internal 1.50V
                                ADC_REFS_2D56:        reference from internal 2.56V
e.g. adcSetReference(ADC_REFS_1D50)
4)        Set current channel for ADC:        void adcSetChannel(u8 chn)
Where: u8 chn:        set current channel of ADC
                                ADC_CHMUX_AN0:                select ADC0(RB0)
                                ADC_CHMUX_AN1:                select ADC1(RB1)
                                ……. Upto……
                                ADC_CHMUX_AN7:         select ADC7(RB7)
                                ADC_CHMUX_V5D:                power monitor (VCC/5)
                                ADC_CHMUX_DAC:                select output of internal DAC
                                ADC_CHMUX_BGR:                select internal Voltage reference
                                ADC_CHMUX_GND:        select system ground level to ADC
                                ADC_CHMUX_DAP:                select output of internal DAP
e.g. adcSetChannel(ADC_CHMUX_AN0)
5)        Read converted data of current channel:                u16 adcRead(void)
6)        Read ADC data from a given channel:        u16 adcReadChannel(u8 chn)
W here: u8 chn:        set current channel of ADC
                                ADC_CHMUX_AN0:                select ADC0(RB0)
                                ADC_CHMUX_AN1:                select ADC1(RB1)
                                ……. Upto……
                                ADC_CHMUX_AN7:         select ADC7(RB7)
                                ADC_CHMUX_V5D:                power monitor (VCC/5)
                                ADC_CHMUX_DAC:                select output of internal DAC
                                ADC_CHMUX_BGR:                select internal Voltage reference
                                ADC_CHMUX_GND:        select system ground level to ADC
                                ADC_CHMUX_DAP:                select output of internal DAP
e.g. adcReadChannel(ADC_CHMUX_AN0)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 10:16:55 | 显示全部楼层
M) DAP Module
1)        Enable DAP module:                void dapEnable()
2)        Disable DAP module:                void dapDisable()
3)        Set gain of DAP module:        void dapSetGain(u8 gain)
Where: u8 gain:                DAP_GAIN_X1:        set DAP gain to X1
                                        DAP_GAIN_X8:        set DAP gain to X8
                                        DAP_GAIN_X16:        set DAP gain to X16
                                        DAP_GAIN_X32:        set DAP gain to X32
        e.g. dapSetGain(DAP_GAIN_X8)
4)        Select negative input for DAP:        void dapSetDNS(u8 dns)
Where: u8 dns:                select negative input source
                                        DAP_DNS_RB0:        negative input from RB0
                                        DAP_DNS_RB1:        negative input from RB1
                                        DAP_DNS_RB2:        negative input from RB2
                                        DAP_DNS_RB3:        negative input from RB3
                                        DAP_DNS_GND:        tied to ground
e.g. dapSetDNS(DAP_DNS_RB0)
5)        Select positive input for DAP:        void dapSetDPS(u8 dps)
Where: u8 dps:                select positive input source
                                        DAP_DPS_ADMX:        from ADC’s channel multiplex
                                        DAP_DPS_RA2:        from APP0/RA2
                                        DAP_DPS_RA5:        from APP1/RA5
                                        DAP_DPS_GND:        tied to ground
e.g. dapSetDPS(DAP_DPS_RB0)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 10:17:57 | 显示全部楼层
N) DAC Module
1)        Enable DAC:        void dacEnable()
2)        Disable DAC:        void dacDisable()
3)        Set DAC IVREF:        void dacSetReference(u8 refs)
Where: u8 refs:        select DAC’s reference source
                                DAC_REFS_VCC:         set DAC source from VCC
                                DAC_REFS_AVREF:         set DAC source from external AVREF
                                DAC_REFS_1D50:         set DAC source from internal 1.50V
                                DAC_REFS_2D56:         set DAC source from internal 2.56V
*Note: Internal IVREF is shared by ADC and DAC module. ADC has more high priority to determine the IVREF settings. If ADC dose not reference IVREF, IVREF can be configurated by dacSetReference()
e.g. dacSetReference(DAC_REFS_1D50)
4)        Set DAC’s output level Vdac=Vref*(dalr+1)/64:        void dacSetLevel(u8 dalr)
5)        Enable DAC output to RA5:        void dacoEnable()
6)        Disable DAC output to RA5:        void dacoDisable()
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-24 14:48 , Processed in 0.049038 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表