Home

MiniOS7 API Functions Reference

image

Contents

1. 100 OffsetError offset is out of range MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page124 6 1 4 256_ReadF Description Read data from SRAM by linear address Prototype unsigned char S256_ReadF unsigned long address Arguments address 0 Ox3FFFF for S256 0 Ox7FFFF for 512 Return Values 0 255 Data sotred in SRAM MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page125 6 1 5 256 _ReadFn Description Read n bytes data from SRAM by linear address Prototype int S256 _ReadFn unsigned long address unsigned num unsigned char buf Arguments address 0 Ox3FFFF for S256 0 Ox7FFFF for 512 num The byte number to read buf The buffer address to store data Return Values 0 NoError Always return 0 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page126 6 1 6 256_WriteF Description Write a byte data to SRAM by linear address Prototype int S256_WriteF unsigned long address unsigned char data Arguments address 0 Ox3FFFF for S256 0 Ox7FFFF for 512 data 0 255 the data to be send out Return Values 0 NoError Always return 0 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page127 6 1 7 256_WriteFn Description Write n bytes data to SRAM by linear address Prototype int S256_WriteFn uns
2. SystemSerialNumber 5 4 Y gt 8 GetComportNumber Y 3 Y e GetSerialNumber 7 Y Y The module can use this function MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page279 14 2 2 SystemSerialNumber Description i 7188X i 8000 UPAC 7186 PDS 700 series can add one serial number IC DS2502 After power on MiniOS7 reads the serial number and save to ram where SystemSerialNumber read data from The serial number length is 8 bytes SystemSerialNumber 0 7 If all values are Ox5A means can not find the hardware IC If all values are OxAA means CRC error for the serial number Use MiniOS7 command VER shows the serial number User s program can use following code to show the serial number Print Serial Number for i 0 i lt 8 i Prototype Print 02X SystemSerialNumber i extern const unsigned char far const SystemSerialNumber NOTE Data source Security SystemSerialNumber Read data from RAM Normal GetSerialNumber Read data from IC High MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page280 14 2 3 GetSerialNumber Description Read system serial number from hardware IC It is unique and 64 bits The application software can check this number for illegal copy Use MiniOS7 command VER shows the serial number Prototype int GetSerialNumber char Serial Arguments Serial Store seria
3. MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page 6 2 2 24 ToComs000 Description This function sends one byte of data to the specified COM Port The data are initially stored in the software output buffer When the hardware output buffer is empty the data are sent using the ISR Interrupt Service Routine Prototype int ToCom8000 int slot int port int data Arguments slot 0 1 2 3 port l 8112 1 8142 1 8142i 0 1 l 8114 1 8144 0 1 2 3 data 0 to 255 the data is ready to be transmitted Return Values 0 On success the data has been stored in the software output buffer 1 The slot or port is invalid 5 Data transmission has failed MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page77 2 2 25 ToComs000Str Description This function sends a string terminated with 0 to the specified COM Port The string initially is stored in the software output buffer When the hardware output buffer is empty the string is sent using the ISR Interrupt Service Routine Prototype int ToCom8000Str int slot int port char str Arguments slot 0 1 2 3 port 1 8112 I 8142 l 8142i 0 1 1 8114 1 8144 0 1 2 3 str The string is ready to be transmitted Return Values 0 On success the string has been stored in the software output buffer 1 The slot or port is invalid 5 Data transmi
4. Y Y GetDo1 Y Y Y Y GetDo2 Y Y Y GetDo3 Y Y Y The module can use this function DO1 1 DO2 Di DI2 a a TXD4 9 a K 5 RXD4 irts1 amp GND GN TXD3 9 TXD1 RXD3 RxD 4 a INIT z S NIT Y D2 9 Y D2 9 G D2 G D2 R Vs R Vs B GND B GND 14 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page233 JUONUT INIT Y D2 G D2 R Vs ZWO B GND 13 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page234 12 1 1 SetDo Functions Description Set DO pins to output high or low on the module Prototype void SetDo1 int mode void SetDo2 int mode void SetDo3 int mode Arguments mode 0 is to output Low 1 is to output High Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page235 12 1 2 GetDI and GetDO Functions Description Get status of DO or DI pins on the module Prototype int GetDi1 void int GetDi2 void int GetDi3 void int GetDo1 void int GetDo2 void int GetDo3 void Arguments None Return Value 0 Status is low others Status is high MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page236 12 2 Expansion Board DIO_AIO For i 7188 i 7188EX WPAC 7186EX series We provide extra functions and library fo
5. data Points to an address that this function want to add data from length Number of data the function attempts to add Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page224 10 3 2 8 Description Modbus_CRC16_Push Push CRC16 value into stack There are 16 layers in the stack Prototype int Modbus _CRC16_Push void Arguments None Return Value 0 On success 1 Stack is overflow MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page225 10 3 2 9 Description Modbus_CRC16_Pop Pop CRC16 value off stack There are 16 layers in the stack Prototype int Modbus _CRC16_Pop void Arguments None Return Value 0 On success 1 Stack is underflow MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page226 10 3 2 10 Modbus_CRC16 Set Description Set current CRC16 value It sets usually CRC16 value to 0 before CRC16 value of a set of data is calculated It can also be called directly CRC16_Reset If it wants to continue CRC16 operation which is not yet finished last time it needs to set CRC16 value of last calculation last time define Modbus CRC16_Reset Modbus _CRC16_Set OxFFFF Prototype void Modbus_CRC16_Set unsigned val Arguments val New CRC16 value Return Value None MinoOS7 API Functions Reference Man
6. Return Value Non negative value Number of bytes written It means disk size is exhausted if this number is smaller than the argument size 2 The argument disk is not the same in the OS7_WriteFile and OS7_OpenWriteFile 3 OS7_OpenWriteFile isn t called before the function is used MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page212 10 3 1 8 OS7_CloseWriteFile Description Write file header and finish write file operation OS7_OpenWriteFile OS7_WriteFile and OS7_CloseWriteFile have to be used together If a write file operation is executed the sequence about use of three functions is OS7_OpenWriteFile first OS7_WriteFile and OS7_CloseWriteFile last File Header typedef struct unsigned mark 0x7188 gt is file unsigned char fname 12 unsigned char year unsigned char month unsigned char day unsigned char hour unsigned char minute unsigned char sec unsigned long size char far addr unsigned CRC unsigned CRC32 FILE_DATA File header item Description mark size addr Auto setting user needn t care them CRC CRC32 fname User defined Year month day Three modes according to OS7_FileDateTimeMode value hour minute sec 1 OS7_FileDateTimeMode 0 default User defined 2 OS7_FileDateTimeMode 1 Auto write default value 2006 01 01 12 00 00 3 OS7_FileDateTimeMode 2 Auto write time value read from RTC re
7. 0 NoError On success MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page47 2 1 39 DataSizelnCom_DMA_x COM Port re ET i 7188XB i 7188XC i 752N i 7188EX i 7188EA ere i 7188EN UPAC 7186EX series PDS 700 series COM 0 Y COM 1 Y COM 2 Y COM 3 Y Y COM 4 Y Y Y The COM Port can use the DataSizelnCom_DMA_ x function Description Direct Memory Access DMA permits the transfer of data between the memory and the peripherals without involvement of the CPU The difference between DataSizelnCom and DataSizelnCom_DMA_ x is the behavior of the data transfer Prototype int DataSizelnCom_DMA_O void int DataSizelnCom_DMA_ 1 void int DataSizelnCom_DMA_2 void int DataSizelnCom_DMA_3 void int DataSizelnCom_DMA_4 void Arguments None Return Value non negative The amount of data in the input buffer 0 means there is no data in the buffer MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page48 2 1 40 ReadComn_DMA_x COM Port T OA i 7188XB i 7188XC i 752N i 7188EX i 7188EA E li 7188EN uPAC 7186EX series PDS 700 series COM 0 Y COM 1 Y COM 2 Y COM 3 Y Y COM 4 Y Y Y The COM port can use the ReadComn_DMA x function Description Direct Memory Access DMA permits the transfer of data between the
8. disk 0 is diskA Others are diskB Return Value Non negative value Free size which can be written data MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page210 10 3 1 6 OS7_OpenWriteFile Description Reserve file head size and write operation is initiated OS7_OpenWriteFile OS7_WriteFile and OS7_CloseWriteFile have to be used together If a write file operation is executed the sequence about use of three functions is OS7_OpenWriteFile first OS7_WriteFile and OS7_CloseWriteFile the last Prototype int OS7_OpenWriteFile int disk Arguments disk 0 is diskA Others are diskB Return Value 0 On success 1_ No enough free size in the disk So write operation can t continue 2_ Pre write operation has not yet finished MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page211 10 3 1 7 OS7_WriteFile Description Write file data OS7_OpenWriteFile OS7_WriteFile and OS7_CloseWriteFile have to be used together If a write file operation is executed the sequence about use of three functions is OS7_OpenWriteFile first OS7 WriteFile and OS7_CloseWriteFile last Prototype int OS7_WriteFile int disk void buf int size Arguments disk 0 is diskA Others are diskB buf Points to a buffer that the function writes the bytes from size Number of bytes the function attempts to write
9. Direct Memory Access DMA permits the transfer of data between the memory and the peripherals without involvement of the CPU The difference between InstallCom and InstallCom_DMA_x is the behavior of the data transfer The InstallCom_DMA_x function has to be called before the other DMA functons are used Prototype int InstallCom_DMA_O unsigned long baud int data int parity int stop int InstallCom_DMA_1 unsigned long baud int data int parity int stop int InstallCom_DMA_2 unsigned long baud int data int parity int stop int InstallCom_DMA_3 unsigned long baud int data int parity int stop int InstallCom_DMA_4 unsigned long baud int data int parity int stop Arguments Am188ES internal UART baud 300 to 115200 bps data 7 8 parity 0 None 1 Even 2 Odd stop 2 data bit must be 7 bit or 1 Return Values 0 NoError On success 2 DataError data is invalid 3 ParityError parity is invalid 4 StopError stop is invalid 13 BaudRateError baud is invalid 20 OutOfMemory The function failed to allocate memory for the output and input buffers MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page45 2 1 37 IsCom_DMA_x COM Port er aiden i 7188XB i 7188XC i 752N i 7 188EX i 7188EA idn li 7188EN uPAC 7186EX series PDS 700 series COM 0 Y COM 1 Y COM 2 Y COM 3 Y Y _ C
10. The string arguments On success MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page260 13 1 4 Ungetchl Description Put one character back to standard I O port s another input buffer Next time when Getch is called it first checks another input buffer and return the data which is put in another input buffer by Ungetchl Prototype int Ungetchl int key Arguments key 0 to 255 If data gt 255 only the low byte are sent out Return Value 0 NoError On success 1 The buffer is full MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page261 13 1 5 Linelnput Description It continuously receives data from standard I O and puts them into buf until receiving OxOD or data number is bigger than maxlen The receiving data in the buf is a string Note If Installcom 1 is called this function is not used Prototype int Linelnput char buf int maxlen Arguments buf The buffer which stores the input data maxlen size of the buffer 1 Return Value The input character number On success MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page262 13 1 6 Putch Description Send one character to standard I O port Note If Installcom 1 is called this function is not used Prototype void Putch int data Arguments data 0 to 255 If data gt 255 only
11. ToCom 4 be used For example EnableMonitorCom4 lf IsCom 4 DisableMonitorCom4 Prototype void EnableMonitorCom4 void Arguments None Return Values None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page93 2 4 2 DisableMonitorCom4 Description This function can let these function that send data to COM4 or receive data from COM4 like IsCom 4 ReadCom 4 ToCom 4 be used For example EnableMonitorCom4 If IsCom 4 DisableMonitorCom4 Prototype void DisableMonitorCom4 void Arguments None Return Values None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page94 3 EEPROM Functions About the EEPROM hardware 1 The EEPROM of the i 7188 i 8000 series modules is 24LC16 contains 8 blocks block O to 7 Each block has 256 bytes address 0 to 255 so the total size of the EEPROM is 2048 2K bytes The block 7 is reserved for MiniOS7 2 The EEPROM of the uPAC 7186 PDS 700 series modules is 24LC128 contains 64 blocks block 0 to 63 Each block has 256 bytes address 0 to 255 so the total size of the EEPROM is 16384 16K bytes The block 63 is reserved for MiniOS7 The default mode for EEPROM is write protected mode Before data can be written to the EEPROM EE_WriteEnable must be called to set EEPROM to write enabled mode 5 After a write operation to the EEPROM is completed it is recommended that the EE_Wr
12. void pascal Show5DigitLed int pos int data Arguments pos pos can be 1 2 3 4 or 5 1 for the leftmost position 5 for the rightmost position data Range from 0 to 17 0 to 15 show the hexadecimal Digit 0 1 A b C d E F 16 show blank 17 show 2 3 E 6 L L 5 af 3 t7 a 3 f 6 7 d Fe a Fe 10 0x0A 11 0x0B 6 6 L T 12 0x0C 13 0x0D 14 0x0E 15 0x0F os 6 E 9 2 4 2 4 2 4 2 4 bad lah la l 16 space 17 dash MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page133 6 gt Jo Ys als Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page134 7 1 5 ShowSDigitLedWithDot Description Show 5 digits of the seven segment LED and also show the DOT Prototype void pascal Showd5DigitLedWithDot int pos int data Arguments pos pos can be 1 2 3 4 or 5 1 for the leftmost position 5 for the rightmost position data range from 0 to 17 0 to 15 show the hexadecimal Digit with dot 0 1 A b C d E F 16 show blank 17 show i 5 t l 5 2 g 2 i g 2 i 10 0x0A 11 0x0B 8 Q 2 4 2 4 2 4 2 4 LI Ls LJ J 12 0x0C 13 Ox0D 14 Ox0E 15 0x0F 6 6 pm 6 fe ffo 5 iB ls if o Ls Lys fal Js 16 s
13. 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page31 2 1 24 SetRtsControlMode COM Port re sata a r i 752N i 7188EX i 7188EA i 7188EN P UPAC 7186EX series PDS 700 series COM 0 COM 1 Y Y Y Y Y COM 2 COM 3 Y Y Y Y COM 4 Y 2 Y Y COM5 Y Y Y com6 ak COM7 coms Y The COM Port can use SetRtsControlMode if there is a RTS pin for the COM Port Description This function sets the flow control RTS CTS for the COM Port The default mode is FLOW_CONTROL_DISABLE The mode definitions are as follows define FLOW_CONTROL_DISABLE 0 define FLOW_CONTROL_ENABLE 1 define FLOW_CONTROL_AUTO_BY_HW 2 define FLOW_CONTROL_AUTO_BY_SW 3 Prototype int SetRtsControlMode int port int mode Arguments port 0 8 for COM0 COM8 mode 1 mode FLOW_CONTROL_DISABLE Either SetCtsControlMode port FLOW_CONTROL_DISABLE or SetRtsControlMode port FLOW_CONTROL_DISABLE is set and the hardware flow control will be disabled 2 mode FLOW_CONTROL_ENABLE This is not used by the SetRtsControlMode function 3 mode FLOW_CONTROL_AUTO_BY_HW Either SetCtsControlMode port FLOW_CONTROL_AUTO_BY_HW or SetRtsControlMode port FLOW_CONTROL_AUTO_BY_HW is set and the automatic hardware flow control will be enabled 4
14. MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page114 4 1 7 _MK_FP_ Description Retrieves a far pointer A far pointer can be used to access the data on the Flash memory directly _MK_FP_ makes a far pointer from its component segment and offset parts This function is particularly for the MSC compiler because MK_FP function has some problems in MSC The code is char far ByteData databyte int far IntData dataint long far LongData datalong ByteData char far MK_FP_ segment offset databyte ByteData IntData int far MK_FP_ segment offset dataint IntData LongData long far MK_FP_ segment offset datalong LongData Prototype int_MK_FP_ unsigned int seg unsigned int offset Arguments seg 0 to 65535 Oxffff offset 0 to 65535 Oxffff Return Value A far pointer On success MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page115 5 NVRAM and RTC Functions About the RTC and NVRAM hardware 1 When the hardware is equipped with a RTC Real Time Clock 31 bytes of NVRAM can be used to store data 2 Only when user s program needs to record know current time date it is needed to use RTC For example if it is wanted to turn on the light at 8 00 AM and turn off it at 5 00 PM 3 NVRAM is SRAM but it uses battary to keep the data so the data in NVRAM does not lost its information when the module is powe
15. PAC 7186EX PDS 700 series series Support Y Y This module is supported Description This function sets EEPROM 24LC16 on the X board to write protected mode Prototype void XEE_WriteProtect void Arguments None Return Values None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page105 3 1 12 XEE_MultiRead i 7 188 i 7188XA i 752N i 7 188EA i 7 1 88EN i 8000 i 7188XB i 7188XC i 7 188EX UPAC 7186EX PDS 700 series series Support Y Y This module is supported Description This function reads multiple bytes of data from the EEPROM 24LC16 on the X board Prototype int XEE_MultiRead int StartBlock int StartAddr int num char databuf Arguments StartBlock 0 to 7 Total is 8 blocks StartAddr 0 to 255 Each block is 256 bytes num 1 to 2048 databuf The address where the data is to be stored Return Values 0 NoError On success 9 AddrError StartAddr is invalid 10 BlockError StartBlock is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page106 3 1 13 XEE_MultiWrite i 7188 i 7188XA i 752N i 7 188EA i 7 1 88EN i 8000 i 7188XB i 7188XC i 7 188EX UPAC 7186EX PDS 700 series series Support Y Y This module is supported Description This function writes data to the EEPROM 24LC16 on the X board Th
16. Return Value Structure pointer Point to the start address of the file information NULL On fail MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page200 10 2 4 GetFilelnfoByName_AB Description define DISKA 0 define DISKB 1 About the diskA or diskB refer to Sec 10 1 Use file name to get file information typedef struct unsigned mark 0x7188 gt is file unsigned char fname 12 unsigned char year unsigned char month unsigned char day unsigned char hour unsigned char minute unsigned char sec unsigned long size char far addr unsigned CRC unsigned CRC32 FILE_DATA Prototype FILE_DATA far GetFilelnfoByName_AB int disk char fname Arguments disk 0 is diskA 1 is diskB fname file name Return Value Structure pointer Point to the start address of the file information NULL On fail MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page201 10 2 5 GetFilePositionByNo_AB Description define DISKA 0 define DISKB 1 About the diskA or diskB refer to Sec 10 1 Use file index to get the start position of file on Flash Memory User can use the address to get file data If file size gt 64K 16 it must use a huge pointer char huge to get file data for offset gt 64K 16 Prototype char far GetFilePositionByNo_AB int disk int num Arguments disk 0 is dis
17. 1 The EEPROM is busy or the StartBlock StartAddr is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page98 3 1 5 EE MultiWrite Description This function writes data to EEPROM The maximum write size is 16 bytes and must be written to the same block 1 An additional limitation is that only the lowest 4 bits of the address can be changed The value variation 0 gt 1 gt 2 gt 3 gt 4 gt 5 gt 6 gt 7 gt 8 gt 9 gt 0xA gt 0xB gt 0xC gt 0xD gt 0xE gt 0xF gt 0 2 The highest 4 bits of the address can t be changed For example EE_MultiWrite 1 21 16 ABCDEFGHIJKLMNOP Block 1 ood 1E OA 87 A4 7C 1F 2C 0161 4E 4F 50 41 42 43 44 O32 25 26 27 26 29 2A 2B O48 J 35 36 37 38 39 3A 3B 064 45 46 47 48 49 4A 45 Casal 55 56 57 58 59 SA 5B CO96 I 65 66 67 68 69 6A 6B 16 bytes A P write to the EEPROM from address 21 0x15 They should end at 36 0x24 But according to this limitation it returns to address 0x10 when data is written to address 0x1F The data L P are written from address 0x10 to 0x14 3 It is recommended that Addr uses 0x00 0x10 0x20 0xF0 Prototype int EE_MultiWrite int Block unsigned Addr int num char Data Arguments Block 0 to block number 1 Now block number is 8 or 64 blocks Addr 0 to 255 Each block is 256 bytes num 1 to 16 The data length Data The starting address of the buffer where the data will be written into E
18. The timer2 adds 1 to TimeTicks per 1 ms It can be used to count time The TimerTicks data type is DWORD unsigned long So the MOV instruction has to move data twice to complete the read operation in a 16 bit CPU If there is timer interrupt to happen during interval of movement twice the final TimeTicks value may be wrong The safe way is to disable interrupt when TimeTicks is read For example unsigned long TT _asm cli TT TimeTicks _asm sti We also provide two functions GetTimeTicks and GetTimeTicks_ISR that both disable interrupt and return TimeTicks value Prototype const unsigned long far TimeTicks MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page191 9 1 4 6 GetTimeTicks Description The timer2 adds 1 to TimeTicks per 1 ms It can be used to count time GetTimeTicks disables timer interrupt and return TimeTicks value For example Original Correspondence long st long st st GetTimeTicks _asm cli st TimeTicks _asm sti According to above table interrupt is enabled after GetTimeTicks is called Prototype long GetTimeTicks void Arguments None Return Value TimeTicks value On success MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page192 9 1 4 7 GetTimeTicks_ISR Description The timer2 adds 1 to TimeTicks per 1 ms It can be used to count time GetTimeTicks_ISR disables timer interrupt and return TimeTicks
19. is set and the hardware flow control will be disabled 2 mode FLOW_CONTROL_ENABLE Enables the RTS CTS software flow control but the user needs to control the active or inactive status of the RTS pin by calling the SetRts8000 function to complete the RTS CTS software flow control 3 mode FLOW_CONTROL_AUTO_BY_HW Either SetCtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_HW or SetRtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_HW is set and the automatic hardware flow control will be enabled 4 mode FLOW_CONTROL_AUTO_BY_SW Both SetCtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_SW and SetRtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_SW are set and the automatic RTS CTS software flow control will be enabled MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page72 Return Values On success The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page73 2 2 22 SetRtsControlMode8000 Description This function sets the flow control RTS CTS for the specified COM Port The default mode is FLOW_CONTROL_DISABLE The mode definitions are as follows define FLOW_CONTROL_DISABLE 0 define FLOW_CONTROL_ENABLE 1 define FLOW_CONTROL_AUTO_BY_HW 2 define FLOW_CONTROL_AUTO_BY_SW 3 Prototype int SetRtsControl Mode8s000 int slot int port int mode Arguments slot 0 1 2 3 port 1 8112 l 8142 I 8142i 0 1 I
20. mode FLOW_CONTROL_AUTO_BY_SW Both SetRtsControlMode port FLOW_CONTROL_AUTO_BY_SW and SetCtsControlMode port FLOW_CONTROL_AUTO_BY_SW are set and the automatic RTS CTS software flow control will be enabled MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page32 Return Values 0 NoError On success 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page33 2 1 25 SetXonXoffControlMode Description This function sets the automatic software flow control Xon Xoff for the COM Port to be enabled or disabled If the COM Port is RS 485 half duplex mode flow control is not required The default mode is 0 Prototype int SetXonXoffControlMode int port int mode Arguments port 0 8 for COM0 COM8 mode 1 Enabled 0 Disabled Return Values 0 NoError On success 1 PortError port is not valid 0 8 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page34 2 1 26 SetRtsActive COM Port er saan aa eee i 752N i 7188EX i 7188EA i 7 188EN ne uPAC 7186EX series PDS 700 series COMO z COM 1 Y Y Y Y Y COM2 a a COM3 Y Y Y Y COM 4 Y Y Y COM5 Y Y Y COM6 i a COM7 COM8 Y The COM Port can use SetRtsActive if there is a RTS
21. version 1 12 Jan 2009 Page17 2 1 11 GetCtsStatus COM Port i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7188EA i 7 188EN UPAC 7186EX series PDS 700 series i 8000 COM 0 COM 1 lt Y COM 2 COM 3 COM 4 lt lt COM 5 lt lt lt lt lt lt COM 6 COM 7 COM 8 Y The COM Port can use GetCtsStatus if there is a CTS pin for the COM Port Description This function reads the status of the CTS pin of the COM Port Prototype int GetCtsStatus int port Arguments port 0 8 for COM0 COMB Return Values nozero For CTS is active low 0 For CTS is not active high 1 Port is not valid 0 8 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page18 2 1 12 InstallCominputData Description This function allows user functions to handle data from the COM Port hardware After InstallComInputData for specified port functions related to input data such as IsCom specified port IsTXBufEmpty specified port ReadCom specified port ReadComn specified port and so on are invalid and the system calls the user function to handle the input data Prototype int InstallComInputData int port int DolnputData unsigned char data Arguments port 0 8 for COM0 COM8 DolnputData A function pointer Return V
22. version 1 12 Jan 2009 Page206 10 3 1 2 DiskAStartSeg_DiskBStartSeg Description Read start segment for diskA or diskB It must call ReadSizeAB to write data to DiskAStartSeg and DiskBStartSeg first and then DiskAStartSeg and DiskBStartSeg can read real value about start segement of disk About the diskA or diskB refer to Sec 10 1 Prototype extern unsigned DiskAStartSeg extern unsigned DiskBStartSeg MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page207 10 3 1 3 AddFarPtrLong Description Move a far pointer Prototype void far AddFarPtrLong void far ptr1 unsigned long size Arguments ptr1 void far pointer size Moving distance Return Value void far A far pointer MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page208 10 3 1 4 OS7_DeleteAllFile Description Delete all file in the disk Prototype int OS7_DeleteAllFile int disk Arguments disk 0 is diskA Others are diskB Return Value 0 On success 1 Delete fail 2 No file in the disk 3 diskB size is zero Only diskA MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page209 10 3 1 5 OS7_GetDiskFreeSize Description Get free size of the disk free size disk total size file head size file data size Prototype long OS7_GetDiskFreeSize int disk Arguments
23. 2 IntVect Description Access 80188 CPU s interrupt vertor table Interrupt vertor table begins at address 00000h that contains up to 256 four byte address pointers containing the address for the interrupt service routine for each possible interrupt type Please refer to AMD 80188 user s manual Am186ES and Am188ES User s Manual for more information Prototype unsigned long far IntVect MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page270 14 1 3 Is7188x and Is8000x Description Check if the program is run under MiniOS7 i 7188x i 8000x u PAC 7186 series It must call InitLib before calling Is7188x Is8000x Is7186e Prototype int ls7188 void int Is7188xa void int Is7188xb void int lIs7188xc void int Is7188e void int Is7186e void int Is8000 void int Is8000Tcp void Arguments None Return Value 0 The program is written for module A but it is downloaded to module B and run The Isxxxx also return 0 Not run on MiniOS7 i 7188x i 8000x pPAC 7186 series 256 Run on MiniOs7 and the flash size is 256K 512 Run on MiniOs7 and the flash size is 512K MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page271 14 1 4 GetLibVersion Description Get the library version of MiniOS7 library Prototype unsigned GetLibVersion void Arguments None Return Value High byte is major version number Low byte is the mi
24. 6 COM 7 COM 8 Y The COM Port can use fCtsControlMode _x if there is a CTS pin for the COM Port Description This function reads the SetCtsControlMode setting mode value Prototype extern int fCtsControlMode_1 extern int fCtsControlMode_ 3 extern int fCtsControlMode_4 extern int fCtsControlMode_5 Arguments Refer to SetCtsControlMode for more details about the CTS setting mode value MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page12 2 1 6 fRtsControlMode_x COM Port i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7188EA i 7 188EN uPAC 7186EX series PDS 700 series i 8000 COM 0 COM 1 lt Y COM 2 COM 3 COM 4 lt lt COM 5 lt lt lt lt lt lt COM 6 COM 7 COM 8 Y The COM Port can use fRtsControlMode_x if there is a RTS pin for the COM Port Description This function reads the SetRtsControlMode setting mode value Prototype extern int fRtsControlMode_1 extern int fRtsControlMode_ 3 extern int fRtsControlMode_4 extern int fRtsControlMode_5 Arguments Refer to SetRtsControlMode for more details about the setting mode value MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page13 2 1 7 ClearCom Description This function clears all the data in input buffer of the COM port Prototype int
25. AIREA EIRE i 752N i 7188EX i 7188EA i 7188EN er uPAC 7186EX series PDS 700 series COM 0 ia COM 1 2 2 1 1 1 COM 2 2 2 1 1 1 2 COM 3 ml 4 a ce 3 2 COM 4 j 1 3 3 3 2 COM 5 E 3 3 COM 6 3 3 3 COM 7 3 3 _ 9 COM 8 3 3 1 Uses Am188ES internal UART 2 Uses 160550 3 Uses 16C550 on the X500 X511 X518 X560 Description This function installs the driver for the COM port for COM1 to COM8 in the interrupt vector which means that all COM ports use the interrupt mechanism to read and write data Input buffer size 1024 bytes Output buffer size 1024 bytes Prototype int InstallCom int port unsigned long baud int data int parity int stop Arguments Am188ES internal UART 16C550 port 0 8 for COM0 COM8 0 8 for COM0 COM8 baud 300 to 115200 bps 300 to 115200 bps data 7 8 5 6 7 8 parity 0 None 1 Even 2 Odd 0 None 1 Even 2 Odd 3 MARK always 1 4 SPACE always 0 stop 2 data bit must be 7 bit or 1 1or2 Return Values 0 NoError On success 1 PortError port is not 0 8 2 DataError data is invalid 3 ParityError parity is invalid 4 StopError stop is invalid 13 BaudRateError baud is invalid 20 OutOfMemory The function failed to allocate memory for the output and input buffers MiniOS7 API Functions Reference Manual version 1 12 Jan 2009
26. API Functions Reference Manual version 1 12 Jan 2009 Page283 14 3 1 Variables of Name or Type of Module Description After system power on or reset MiniOS7 checks if there are any add on modules on l 8000 series and store some respective data on bios area 1 ModuleType 0 7 saves the type of module If bit 7 1 means that module is parallel module 8nnn otherwise that module is 87nnn 2 ModuleName 0 7 stores the module name For example the saved value is 51 if the module is 8051 If the module is 8142 then 142 saved The saved value is nnn if the module is 8nnn or 87nnn If nnn 255 means that there s no module on the slot 3 ModuleFullName 0 contains the full name of the module on slot 0 ModuleFullName 1 contains the full name of the module on slot 1 If there is no module on that slot the value of ModuleFullNamef slot is For example For I 87017 ModuleName slot 17 ModuleFullName slot is 87017 For I 87017ML ModuleNamef slot 17 but ModuleFullNamef slot is 87017ML So if the program uses the ModuleNamef slot it can not point out that module is 87017 or 87017ML but the variable ModuleFullNamef slot can do it 4 The code for use of ModuleType and ModuleName to decide the module on the slot of l 8000 are as follows for i 0 i amp NumberOfSlot i if ModuleType i amp 0x80 Print Slot d 8 03u n r i ModuleName i else if ModuleName i OxFF Print Slot d 870 02d n r i Mo
27. ClearCom int port Arguments port 0 8 for COM0 COMB Return Values 0 NoError On success 1 PortError The port is not valid 0 8 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page14 2 1 8 ClearTxBuffer Description This function clears all data from the output buffer of the COM Port Prototype int ClearTxBuffer int port Arguments port 0 8 for COM0 COM8 Return Values 0 NoError On success 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page15 2 1 9 DataSizelnCom Description This function reads the size of the data in the input buffer of the COM Port Prototype int DataSizelnCom int port Arguments port 0 8 for COM0 COM8 Return Value Non negative Data size in the input buffer 1 PortError port is not valid 0 8 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page16 2 1 10 Description This function reads the value of the available space in the output buffer of the COM Port Prototype GetTxBufferFreeSize int GetTxBufferFreeSize int port Arguments port 0 8 for COM0 COM8 Return Values Non negative The value of the available space in the output buffer 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual
28. buffer for Scanf The default buffer size is 80 bytes if more space is need user s program must support the buffer Prototype void SetScanBuffer unsigned char buf int len Arguments buf The new buffer for Scanf to use len Length of buffer 1 Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page267 13 1 11 Scanf Description Like C s scanf C s scanf cannot used on MSC VC Note If Installcom 1 is called this function is not used Prototype int Scanf char fmt Arguments Please refer to C s library reference Return Value The number of input fields successfully scanned converted and stored On success The return value does not include scanned fields that were not stored 0 No fields were stored EOF Attempts to read at end of string MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page268 14 Others MISC Functions 14 1 Common Functions Variables for all i 7188 i 8000 uPAC 7186 PDS 700 Series 14 1 1 InitLib Description Initialize parameters about hardware in the library This is an important function It must be called before any other functions are used in the library It results in unpredictable error if InitLib doesn t be used Prototype void InitLib void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page269 14 1
29. define MSR_CTS 0x10 define MSR_DSR 0x20 define _MSR_RI 0x40 define MSR_DCD 0x80 Prototype int GetCom8000_MSR int slot int port Arguments slot 0 1 2 3 port 1 8112 I 8142 1 8142i 0 1 1 8114 I 8144 0 1 2 3 Return Value The 8 bit status of the MSR On success 1 The slot or port is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page66 2 2 16 IsCom8s000 Description This function checks if there is any data in the input buffer of the specified COM Port Prototype int lsCom8000 int slot int port Arguments slot 0 1 2 3 port 1 8112 I 8142 l 8142i 0 1 I 8114 I 8144 0 1 2 3 Return Values Non zero integer Data number in the input buffer 0 No data is available 7 A buffer overflow has occured Calling ReadCom8000 or ClearCom8000 or ReadCom8000nBytes to reset the overflow status MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page67 2 2 17 IsCom8s0000utBufEmpty Description This function checks if the software output buffer of specified COM Port is empty All data was transmitted Prototype int lsCom8000O0utBufEmpty int slot int port Arguments slot 0 1 2 3 port 1 8112 l 8142 I 8142i 0 1 1 8114 1 8144 0 1 2 3 Return Values 1 The output buffer is empty 0 The output buffer is not empty 1 On error MiniOS7 API Functi
30. out of range MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page154 9 1 2 1 6 StopWatchStart Description Start to use a StopWatch channel and reset the StopWatch value to 0 Refer to TimerOpen TimerClose Then the system timer ISR Interrupt Service Routine increases the StopWatch value by 1 every 1 ms Prototype int StopWatchStart int channel Arguments channel 0 7 total 8 channels Return Value 0 NoError On success 15 ChannelError channel is out of range MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page155 9 1 2 1 7 StopWatchStop Description Disable the StopWatch channel Then the system timer ISR Interrupt Service Routine stops to increase the StopWatch value Refer to TimerOpen TimerClose Prototype int StopWatchStop int channel Arguments channel 0 7 total 8 channels Return Value 0 NoError On success 15 ChannelError channel is out of range MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page156 9 1 2 1 8 StopWatchPause Description Pause the StopWatch After calling StopWatchPause it can call Stop WatchContinue to continue count time Refer to TimerOpen TimerClose Prototype int StopWatchPause int channel Arguments channel 0 7 total 8 channels Return Value 0 NoError On success 15 ChannelError ch
31. pin for the COM Port Description This function sets the output of the RTS pin of the COM Port to LOW RS 232 is low active Prototype int SetRtsActive int port Arguments port 0 8 for COMO COM8 Return Values 0 NoError On success 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page35 2 1 27 COM Port SetRtsInactive i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7188EA i 7 188EN uPAC 7186EX series PDS 700 series i 8000 COM 0 COM 1 lt Y COM 2 COM 3 COM 4 lt lt COM 5 lt lt lt lt COM 6 COM 7 COM 8 Y The COM Port can use SetRtsInactive if there is a RTS pin for the COM Port Description Set COM port s RTS pin output HIGH RS 232 is low active Prototype int SetRtsInactive int port Arguments port 0 8 for COM0 COMB The RTS pin is effective based on the list above Return Values 0 NoError On success 1 PortError port is not valid 0 8 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page36 2 1 28 SetBaudrate Description This function sets the Baud Rate of the COM Port Prototype int SetBaudrate int port unsigned long baud Arguments port 0 8 for COM0 COM8 baud The new Baud Rate C
32. size of the buf Return Values The specified amount of data to be read On success from the input buffer 1 The slot or port is invalid 6 There is no data in the input buffer of the specified COM Port MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page70 2 2 20 SetRts8000 Description This function sets the RTS Request To Send pin for the specified COM Port as active or inactive Prototype int SetRts8000 int slot int port int mode Arguments slot 0 1 2 3 port 1 8112 l 8142 l 8142i 0 1 1 8114 l 8144 0 1 2 3 mode 1 Active 0 Inactive Return Values 0 On success 1 The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page71 2 2 21 SetCtsControlMode8000 Description This function sets the flow control RTS CTS for the specified COM Port The default mode is FLOW_CONTROL_DISABLE The mode definitions are as follows define FLOW_CONTROL_DISABLE 0 define FLOW_CONTROL_ENABLE 1 define FLOW_CONTROL_AUTO_BY_HW 2 define FLOW_CONTROL_AUTO_BY_SW 3 Prototype int SetCtsControlMode8s000 int slot int port int mode Arguments slot 0 1 2 3 port 1 8112 l 8142 l 8142i 0 1 1 8114 1 8144 0 1 2 3 mode 1 mode FLOW_CONTROL_DISABLE Either SetCtsControlMode8000 slot port FLOW _CONTROL_DISABLE or SetRtsControlMode8000 slot port FLOW_CONTROL_DISABLE
33. with pull high for some pin is pull low 2 Set the PIO pin to Input mode without pull high low 3 Set the PIO pin to normal mode Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page248 12 4 3 SetPio Description Set the PIO pins of CPU to output High Low General purpose function for all PIO pins Please be careful to use this function IH NOT ALL 32 PIO pins can be used by user These pins which can be used are like PIO 6 ARDY 1 TMROUT1 10 TMROUTO O TMRIN1 11 TMRIN 1 4 DT R 9 A19 14 MCSO 30 INT4 Prototype void SetPio int pin int mode Arguments pin 0 31 mode 0 Set the PIO pin to output Low 1 Set the PIO pin to output High Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page249 12 4 4 Description GetPio Get the status of the PIO pins of CPU Prototype int GetPio int pin Arguments pin 0 31 Return Value 0 1 For input mode the input is low 2 For output mode current output is low non zero 1 For input mode the input is high 2 For output mode current output is high MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page250 12 4 5 Set PIO Direction Functions Description Set the some PIO pins of CPU to Input Output mode These PIO pins connect to I O expansion bus About the I O expansion
34. you have any problem please contact service icpdas com 1 Library Selection for All i 7188 i 8000 uPAC 7186 PDS 700 Series Modules For i 7188XA i 7188XB i 7188XC i 752N i 7521 i 7522 i 7523 i 7522A i 7524 i 7527 i 7188EX i 7188EA i 7188EN i 7188E1 i 7188E2 i 7188E3 i 7188E4 i 7188E5 i 7188E8 PDS 720 PDS 721 PDS 732 PDS 734 PDS 742 PDS 743 PDS 752 PDS 755 PDS 762 PDS 782 pPAC 7186EX D pPAC 7186EX D FD pPAC 7186EX D FM I HPAC 7186EX D SM Supports a single memory model 1 7188EL LIB 7188XAL LIB 7188XBL LIB 7188XCL LIB 7186EL LIB is for LARGE Memory MODEL TC BC MSC MSVC All function declarations are included in the 7188x h 7186x h file so the following line should be added to the beginning of the program include 7188E h for i 7188EX i 7188EA i 7188EN include 7186E h for PDS 700 series uPAC 7186EX series include 7188XA h for i 7188XA include 7188XB h for i 7188XB i 7522A i 7524 i 7527 include 7188XC h for i 7188XC i 7521 i 7522 i 7523 For i 8000 series modules Supports a single memory model 1 8000E LIB is for LARGE Memory MODEL TC BC MSC MSVC All function declarations are included in 8000E h file so the following line should be added to the beginning of the program include 8000E h 8000E LIB and 8000E h are located in the following directory Companion CD Napdos 8000 841x881x Demo Lib or http
35. 009 Page299 16 Version detailed information Ver 1 11 1 Fixed ToComBufn function return value Old content 0 NoError On success 1 PortError port is not valid 0 8 5 TimeOut Timeout The new content is used for the library whose library date is 2007 7 24 and later Refer to GetLibDate Ver 1 12 1 Added tell what areas are reserved in EEPROM in chapter EEPROM Functions MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page300
36. 1 12 Jan 2009 Page188 9 1 4 3 Delay_1 Description Delay some time interval the time unit is 0 1ms There are three timers in CPU Delay_1 uses the timer0 to do the delay operation If user wants to change the timer for Delay_1 please refer to SetDelayTimer When InstallUserTimerFunction_us InstallUserTimerFunction_ms and Delay_1 are used together user has to set different timer for them If not they clash with each other The SetDelayTimer and SetUserTimer can set timerO or timer to be used Prototype void Delay_1 unsigned ms Arguments ms the delay time Unit is 0 1ms Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page189 9 1 4 4 Delay_2 Description Delay some time interval the time unit is 0 01ms There are three timers in CPU Delay_2 uses the timer0 to do the delay operation If user wants to change the timer for Delay_2 please refer to SetDelayTimer When InstallUserTimerFunction_us InstallUserTimerFunction_ms and Delay_2 are used together user has to set different timer for them If not they clash with each other The SetDelayTimer and SetUserTimer can set timerO or timer to be used Prototype void Delay_2 unsigned ms Arguments ms the delay time Unit is 0 01ms Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page190 9 1 4 5 TimeTicks Description There are three timers in CPU
37. 1 SetBreakMode Description This function sends a BREAK signal to the COM Port or stop a BREAK signal from being sent to COM Port Prototype int SetBreakMode int port int mode Arguments port 0 8 for COMO COM8 mode 1 Start sending a BREAK signal 0 Stop sending a BREAK signal Return Value 0 NoError On success 1 PortError port is not valid 0 8 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page40 2 1 32 ToCom Description This function sends one byte of data to the COM Port The data are stored in the output buffer first then when the hardware output buffer is empty the data are sent by the ISR Prototype int ToCom int port int data Arguments port 0 8 for COM0 COM8 data 0 255 the data to be transmitted Return Values 0 NoError On success 1 PortError port is not valid 0 8 5 TimeOut Timeout MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page41 2 1 33 ToComStr Description This function sends a string ending with 0 to the COM Port Prototype int ToComStr int port char str Arguments port 0 8 for COM0 COM8 str The string to be transmitted Return Values 0 NoError On success 1 PortError port is not valid 0 8 5 TimeOut Timeout MiniOS7 API Functions Reference Manual version 1 12 Jan 200
38. 12 4 10 ClockLow Description Set PIO pin 26th of CPU to output low The PIO pin 26th connects to SCLK pin of I O expansion bus About the I O expansion bus pins please refer to I O Expansion Bus for 7188X 7188E User s Manual Prototype void ClockLow void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page256 12 4 11 ClockHighLow Description Send a clock from the PIO pin 26th of CPU Set it to high first then set it to low The PIO pin 26th connects to SCLK pin of I O expansion bus About the I O expansion bus pins please refer to I O Expansion Bus for 7188X 7188E User s Manual Prototype void ClockHighLow void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page257 13 Standard IO Functions Remark COM 1 of i 7188 i 8000 PDS 700 uPAC 7186 series is the standard I O port Before user s program calls InstallCom 1 user can use all functions of this section to send receive data to from COM1 Note The standard I O port of l 7188 amp I 7188XA is COM4 All functions of this section do not work after Installcom 1 is called It must use IsCom 1 ToCom 1 ReadCom 1 to send receive data to from COM1 These functions work again until RestoreCom 1 is called Note For l 7188 amp I 7188XA are Installcom 4 RestoreCom 4 IsCom 4 Scanf c
39. 2 1 21 SetComTimeout Description When the output buffer is full the ToCom function waits for t ms to check whether there is any free space in the output buffer to store data The default value is 10 ms Prototype int SetComTimeout int port unsigned t Arguments port 0 8 for COM0 COM8 t 0 65535 for the timeout value The unit is ms Return Value 0 NoError On success 1 PortError port is not valid 0 8 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page28 2 1 22 SetComPortBufferSize Description This function sets the input and output buffer size for the Com Port The default value for both the input and output buffer size is 1024 Prototype int SetComPortBufferSize int port int in_size int out_size Arguments port 0 8 for COM0 COM8 in_size 0 32767 out_size 0 32767 Return Values 0 NoError On success 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page29 2 1 23 COM Port SetCtsControlMode i 752N i 7188EX i 7188EA i 7 188EN UPAC 7186EX series PDS 700 series i 7188 i 7188XA i 7188XB i 7188XC i 8000 COM 0 COM 1 lt Y COM 2 COM 3 COM 4 lt lt COM 5 lt lt lt lt COM 6 COM 7 COM 8 Y The C OM Port can use S
40. 2 GetSystemKey Description On l 8000 series system support 4 keys SET MODE UP and DOWN GetSystemKey reads one key input value from system key input buffer FIFO buffer size is 16 If there is no system key input value the function waits until any system key input If InstallNewTimer is called it must use _GetSystemKey instead of GetSystemKey Prototype int GetSystemKey void int _GetSystemKey void Arguments None Return Value 1 SKEY_SET For SET key 2 SKEY_MODE For MODE key 3 SKEY_UP For UP key 4 SKEY_DOWN For DOWN key Note KeyStatus GetSystemKey _GetSystemKey Difference 1 Read current system key values 1 Read FIFO buffer value 2 Four key data one time 2 One key data one time 3 Real time data 3 May be real time data MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page295 14 3 13 ClearSystemKey Description Clear all data in the System key input buffer If InstallNewTimer is called it must use _ClearSystemKey instead of ClearSystemKey Prototype void ClearSystemKey void void _ClearSystemKey void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page296 14 3 14 InstallNewTimer Description It changes system timer default is timer2 to another new timer and shorts the time of timer interrupt executing After InstallNewTimer is called it s
41. 2009 Page25 2 1 19 ReadCom Description This function reads one byte of data from the input buffer of the COM Port Prototype int ReadCom int port Arguments port 0 8 for COM0 COM8 Return Values 0 255 Data read 1 PortError port is not valid 0 8 6 QueueEmpty The queue is empty MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page26 2 1 20 ReadComn Description This function reads N bytes of data from the input buffer of the COM Port at one time For example Num is the total number of bytes in the input buffer of the COM Port If n lt Num N n So n bytes of data are read from the input buffer of the COM Port at one time If n gt Num N Num So Num bytes of data are read from the input buffer of the COM Port at one time Prototype int ReadComn int port unsigned char buf int n Arguments port 0 8 for COM0 COM8 buf The data buffer stores the data that is read from the input buffer of the COM Port n The maximum number of bytes that can be read from the input buffer of the COM port if n lt Num The n value must be less than or equal to the size of buf Return Value Non negative The specified amount of data that has been read from the input buffer 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page27
42. 5 constant defined for i 7188 i 8000 uUPAC On fail 7186 PDS 700 series MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page231 11 1 3 ReceiveResponseFrom7000_ms Description After calling SendCmdTo7000 user can call ReceiveResponseFrom7000_ms to get the response from 7000 or I 87K Prototype int ReceiveResponseFrom7000_ms int iPort unsigned char cCmd long ITimeout int iChksum Arguments iPort 1 to 8 for i 7188 uPAC 7186 PDS 700 series 0 1 3 4 for i 8000 series cCmd Response received from 7000 or l 87K If checksum is enabled the function checks and remove the checksum The CR is removed ITimeout Set the timeout unit is ms iChksum 1 is to enable checksum 0 is to disable checksum Return Value NoError On success Error code refer to Sec 15 constant defined for i 7188 i 8000 UPAC On fail 7186 PDS 700 series MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page232 12 Programmable IO Functions 12 1 On Board DIO for i 7188 PAC 7186 PDS 700 Series Functions i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7188EA i 7 188EN i 8000 PDS 700 series UPAC 7 186EX UPAC 7186EX FD uPAC 7186EX FM UPAC 7186EX SM SetDo1 Y Y Y Y SetDo2 Y Y Y SetDo3 Y Y GetDi1 Y Y Y GetDi2 Y Y Y GetDi3
43. 8112 l 8142 8142i 0 1 1 8114 l 8144 0 1 2 3 Return Values 0 On success 1 The slot or port is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page58 2 2 8 ClearCom8000TxBuffer Description This function clears all the data from the output buffer of the specified COM Port Prototype void ClearCom8000TxBuffer int slot int port Arguments slot 0 1 2 3 port 1 8112 l 8142 I 8142i 0 1 I 8114 I 8144 0 1 2 3 Return Values 0 On success 1 The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page59 2 2 9 CirMsrChanged8s000 Description This function clears the parameter that records the change of status of the Modem Status Register MSR for the specified COM Port Prototype void ClrMsrChanged8000 int slot int port Arguments slot 0 1 2 3 port 1 8112 I 8142 1 8142i 0 1 1 8114 I 8144 0 1 2 3 Return Values None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page60 2 2 10 GetMsrChanged8000 Description This function checks whether the status of the Modem Status Register MSR for the specified COM Port has changed recently Prototype int GetMsrChanged8000 int slot int port Arguments slot 0 1 2 3 port 1 8112 l 8142 I 8142i 0 1 I 8114 I 8144 0 1 2 3 Return Values 1 The status of the MS
44. 8114 1 8144 0 1 2 3 mode 1 mode FLOW_CONTROL_DISABLE Either SetCtsControlMode8000 slot port FLOW _CONTROL_DISABLE or SetRtsControlMode8s000 slot port FLOW_CONTROL_DISABLE is set and the hardware flow control will be disabled 2 mode FLOW_CONTROL_ENABLE This is not used by the SetRtsControlMode8000 function 3 mode FLOW_CONTROL_AUTO_BY_HW Either SetCtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_HW or SetRtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_HW is set and automatic hardware flow control will be enabled 4 mode FLOW_CONTROL_AUTO_BY_SW Both SetCtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_SW and SetRtsControlMode8000 slot port FLOW_CONTROL_AUTO_BY_SW are set and the automatic RTS CTS software flow control will be enabled Return Values MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page74 0 Onsuccess The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page75 2 2 23 SetCom8000FifoTriggerLevel Description This function sets the receiver FIFO trigger level bytes for the specified COM Port The default trigger level value is 8 bytes Prototype int SetCom8000FifoTriggerLevel int slot int port int level Arguments slot 0 1 2 3 port 1 8112 l 8142 8142i 0 1 1 8114 l 8144 0 1 2 3 level 1 4 8 14 bytes Return Values 1 The slot or port is invalid
45. 9 Page42 2 1 34 ToComBufn Description This function sends n bytes of data to the COM port Prototype int ToComBufn int port char buf int num Arguments port 0 8 for COM0 COM8 buf The data buffer num The amount of data bytes transmitted Return Values Non negative Bytes number that had been transmitted 0 buf is null or num lt 0 1 PortError port is not valid 0 8 Note For the library whose library date is 2007 7 24 and later Refer to GetLibDate Refer to Sec 16 to know the content modification about ToComBufn MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page43 2 1 35 WaitTransmitOver Description This function waits all data in the output buffer of the software and the hardware of the COM Port to be sent Prototype int WaitTransmitOver int port Arguments port 0 8 for COM0 COM8 Return Values 0 NoError On success 1 PortError port is not valid 0 8 5 TimeOut Timeout MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page44 2 1 36 InstallCom_DMA_x COM Port T A i 7188XB i 7188XC i 752N i 7188EX i 7188EA E li 7188EN uPAC 7186EX series PDS 700 series COM 0 Y COM 1 Y COM 2 Y COM 3 Y Y COM 4 Y Y Y The COM Port can use the InstallCom_DMA x function Description
46. D i 8000 SetPioDir lt SetPio lt GetPio SetDio4Dir lt SetDio9Dir SetDio14Dir SetTi0Dir SetTi1Dir SetToODir SetTo1Dir GetDio4 GetDio9 GetDio14 GetTi0 GetTo0 GetTi1 GetTo1 SetDio4High SetDio9High SetDio14High SetTiOHigh SetToOHigh SetTi1High SetTo1High SetDio4Low SetDio9Low SetDio14Low SetTi0OLow SetToOLow SetTi1Low SetTo1Low lt lt lt lt lt x lt lt x lt lt lt lt x lt lt lt lt x lt lt lt lt lt lt x lt lt lt MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page246 ClockHigh Y Y Y ClockLow Y Y Y ClockHighLow Y Y Y Y The module can use this function MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page247 12 4 2 SetPioDir Description Set the PIO pins of CPU to Input Output mode General purpose function for all PIO pins Please be careful to use this function IH NOT ALL 32 PIO pins can be used by user These pins which can be used are like PIO 6 ARDY 1 TMROUT1 10 TMROUTO O TMRIN1 11 TMRIN1 4 DT R 9 A19 14 MCSO 30 INT4 Prototype void SetPioDir unsigned pin int dir Arguments pin 0 31 dir Set the PIO pin to output mode 0 1 Set the PIO pin to input
47. Description This function sets the configuration for each port of the slot Automatic hardware and software flow control CTS RTS are supported Installing the driver for the slot means installing the interrupt service routine In other words each port of the slot reads or writes data using the interrupt method After running InstallCom8000 the default setting values as follows Input buffer 1024 bytes Output buffer 1024 bytes Baud Rate 9600bps data bit 8 parity bit none stop bit 1 Automatic Hardware or software flow control CTS RTS is disabled Prototype int InstallCom8000 int slot Arguments slot 0 1 2 3 Return Values 0 On success 1 No module is attached to the slot 2 The configuration settings for any port of the slot failed MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page54 2 2 4 RestoreCom8s000 Description If an application calls InstallCom8000 RestoreCom8000 must then be called to restore the COM Port settings before exiting the application Prototype int RestoreCom8000 int slot Arguments slot 0 1 2 3 Return Values 0 On success 1 There is no module attached to the slot MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page55 2 2 5 _SetBaudrate Description This function sets the Baud Rate for the specified COM Port After calling InstallCom8000 the default Baud Rate valu
48. Description Pause the countdowntimer It makes cdt gt ulPauseTime current TimeTicks typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype void T_CountDownTimerPause COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page167 9 1 2 2 7 T_ CountDownTimerContinue Description Continue the countdowntimer typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype void T_CountDownTimerContinue COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page168 9 1 2 2 8 T_ CountDownTimerlsTimeUp Description Check the time of countdown is up or not typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype int T_CountDownTimerls TimeUp COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value Time isn t up 1 Time is up MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page169 9 1 2 2 9 T_ CountDownTimerGetTimeLeft Description Get remnant time of countdown typedef st
49. ED display Afer initializing all segments are lighted off The Init5DigitLed has to be called before the other functions about 5 digits of seven segment LED are called Prototype void Init5DigitLed void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page130 7 1 2 Disable5DigitLed Description Disable the scan circuit for 5 digits of seven segment LED All digits are turned off Prototype void Disable5DigitLed void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page131 7 1 3 Enable5DigitLed Description Enable the scan circuit for 5 digits of seven segment LED An example of code Init5DigitLed Show5DigitLed 1 1 Show5DigitLed 2 2 Show5DigitLed 3 3 Show5dDigitLed 4 4 ShowsDigitLed 5 5 Delay 2000 the 5 digits of seven segment LED is like fig 1 Disable5DigitLed Delay 2000 the 5 digits of seven segment LED is like fig 2 Enable5DigitLed the 5 digits of seven segment LED is like fig 3 aag Qo ne gt o Prototype void Enable5DigitLed void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page132 7 1 4 Show5DigitLed Description Show 5 digits of the seven segment LED Prototype
50. EPROM Return Values 0 NoError On success 1 The EEPROM is busy or the Block or Addr is invalid Note The block 7 or 63 is reserved for MiniOS7 Please don t use it MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page99 3 1 6 EE MultiRead_L Description This function reads multiple bytes of data from the EEPROM Prototype int EE_MultiRead_L unsigned address unsigned num char Data Arguments address 0 to 2047 16383 2K 16K num 1 to 2048 The data length Data The address where the data is stored Return Values 0 NoError on success 1 The EEPROM is busy or the address is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page100 3 1 7 EE_MultiWrite_L Description The function writes multiple bytes of data to the EEPROM Prototype int EE_MultiWrite_L unsigned address unsigned no char Data Arguments address 0 to 2047 16383 2K 16K no 1 to 2048 16384 Data length Data The starting address of the buffer where the data is stored Return Values 0 NoError On success 1 The EEPROM busy or the address is invalid 2 The no address is out of range Note The address 1792 2047 16128 16383 are reserved for MiniOS7 Please don t use them MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page101 3 1 8 XEE_Init i 7 188
51. EX FD uPAC 7186EX FM UPAC 7186EX SM SizeAB Y DiskAStartSeg Y DiskBStartSeg Y Y OS7_FileDateTimeMode Y The module can use these variables Functions i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7 188EA i 7 188EN PDS 700 series uPAC 7186EX uPAC 7186EX FD UPAC 7186EX FM uPAC 7186EX SM i 8000 AddFarPtrLong Y OS7_DeleteAllFile OS7_GetDiskFreeSize OS7_OpenWriteFile OS7_WriteFile OS7_CloseWriteFile CRC16_ Push CRC16_MakeTable CRC16_Pop CRC16_Set CRC16_Read CRC16_AddData CRC16_AddDataN lt lt lt lt x lt x lt lt lt Modbus_CRC16_Push Modbus_CRC16_Pop Modbus_CRC16_Set Modbus _CRC16_Read lt lt lt lt lt lt lt lt lt lt lt lt x MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page205 Modbus_GetCRC16 Y Y The module can use this function 10 3 1 1 SizeAB Description Read size for diskA diskB and reserved sizeC It must call ReadSizeAB to write data to SIZE_AB first and then SizeAB can read real value about size of disk About the diskA or diskB refer to Sec 10 1 typedef struct unsigned sizeA 3 unsigned sizeB 3 unsigned sizeC 3 unsigned sum 7 SIZE_AB Prototype extern SIZE_AB SizeAB MiniOS7 API Functions Reference Manual
52. Functions Reference Manual version 1 12 Jan 2009 Page85 2 2 33 WaitCom8000TransmitOver Description This function waits for all data in the software and hardware output buffers of of the specified COM Port to be tramsmitted Prototype int WaitCom8000TransmitOver int slot int port Arguments slot 0 1 2 3 port 1 8112 l 8142 I 8142i 0 1 1 8114 1 8144 0 1 2 3 Return Values 0 On success 1 The slot or port is invalid 5 Timeout MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page86 2 3 COMO0O_use_DMA for i 8000 Series GE aln Aii AL pain E ALLII MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page87 2 3 1 OpenCom0UseDMA Description This function uses Direct Memory Access DMA method to transmit receive data to from COMO This function has to be called first and then other DMA functions for COMO can be used Prototype void OpenCom0UseDMA void Arguments None Return Values None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page88 2 3 2 CloseCom0UseDMA Description This function closes the Direct Memory Access DMA method for COMO Prototype void CloseCom0UseDMA void Arguments None Return Values None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page89 2 3 3 Com0GetDataSize Description This function retrieves the size of the data currently
53. MiniOS7 API Functions Reference Manual For C Language Version 1 12 Jan 2009 Original Writer Tim Tsai Last Editer Vic Tsai i 7188 series i 7188 D i 7188XA D i 7188XB D i 7188XC D i 7188EX D i 7188EA D i 752N i 7521 D i 7522 D i 7523 D i 7522A D i 7524 D i 7527 D i 7188EN i 7188E1 D i 7188E2 D i 7188E3 D i 7188E4 D i 7188E5 D i 7188E8 D i 8000 series i 8411 i 8811 i 8431 i 8831 i 8431 80 i 8831 80 PDS 700 series PDS 720 D PDS 721 D PDS 732 D PDS 734 D PDS 742 D PDS 743 D PDS 752 D PDS 755 D PDS 762 D PDS 782 D UPAC 7186 series uPAC 7186EX D uPAC 7186EX D FD UPAC 7186EX D FM UPAC 7186EX D SM MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page History Ver 1 1 1 Added PDS 700 series model number 2 Added uPAC 7186EX series model number Ver 1 11 1 Fixed ToComBufn function return value 2 New Sec 2 1 42 SetComFifoTriggerLevel MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page2 Introduction This manual is to develop user s own application programs with those embedded controllers listed above This manual introduces what kinds of functions a library has what kinds of libraries can be used with a embedded controller and detail descriptions of those libraries and their corresponding functions If
54. OM 4 Y Y Y The COM Port can use the IsCom_DMA_x function Description Direct Memory Access DMA permits transfer of data between the memory and the peripherals without involvement of the CPU The difference between IsCom and IsCom_DMA_x is the behavior of the data transfer Prototype int lsCom_DMA_O void int lsCom_DMA_1 void int ls Com_DMA_2 int lsCom_DMA_3 void int lsCom_DMA_4 void Arguments None Return Values 0 QueuelsEmpty There is no data in the input buffer of the COM Port 1 QueuelsNotEmpty There is data in the input buffer of the COM Port MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page46 2 1 38 ClearCom_DMA_x COM Port T Tr i 7188XB i 7188XC i 752N i 7 188EX i 7188EA A000 i 7188EN UPAC 7186EX series PDS 700 series COM 0 Y COM 1 Y COM 2 Y COM 3 Y Y COM 4 Y Y Y The COM Port can use the ClearCom_DMA _x function Description Direct Memory Access DMA permits the transfer of data between the memory and the peripherals without involvement of the CPU The difference between ClearCom and ClearCom_DMA_x is the behavior of the data transfer Prototype int ClearCom_DMA_O void int ClearCom_DMA_1 void int ClearCom_DMA_2 void int ClearCom_DMA_3 void int ClearCom_DMA_4 void Arguments None Return Value
55. Pages 2 1 2 bCtsChanged_x COM Port a anaes eee ee ae i 752N i 7188EX i 7188EA i 7188EN T uPAC 7186EX series PDS 700 series COM 0 COM 1 Y Y Y Y Y COM 2 COM 3 Y Y Y Y COM 4 Y Y Y COM 5 Y Y Y COM 6 COM 7 COM 8 Y The COM Port can use bCtsChanged_x if there is a CTS pin for the COM Port Description This function checks whether the CTS pin has changed The variable indicates that the CTS pin has changed state since the last time it was ready by the CPU Prototype extern int bCtsChanged_1 extern int bCtsChanged_3 extern int bCtsChanged_4 extern int bCtsChanged_5 Arguments bCtsChanged_x 1 The CTS pin has changed state since the last time it was ready by the CPU bCtsChanged_x 0 The CTS pin hasn t changed state since the last time it was ready by the CPU MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page9 2 1 3 CurCTS_x COM Port i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7188EA i 7188EN uPAC 7186EX series PDS 700 series i 8000 COM 0 COM 1 lt Y COM 2 COM 3 COM 4 lt lt COM 5 lt lt lt lt lt lt COM 6 COM 7 COM 8 Y The COM Port can use CurCTS _x if there is a CTS pin
56. R has changed recently There has been no change 1 The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page61 2 2 11 GetCtsControlMode8000 Description For the specified COM Port this function retrieves the latest flow control mode that the SetCtsControlMode8000 was set to Default mode is FLOW_CONTROL_DISABLE The mode definitions are as follows define FLOW_CONTROL_DISABLE 0 define FLOW_CONTROL_ENABLE 1 define FLOW_CONTROL_AUTO_BY_HW 2 define FLOW_CONTROL_AUTO_BY_SW 3 Prototype int GetCtsControlMode8s000 int slot int port Arguments slot 0 1 2 3 port 1 8112 I 8142 1 8142i 0 1 1 8114 I 8144 0 1 2 3 Return Values 0 1 2 3 On success 1 The slot or port is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page62 2 2 12 GetCom8s000TxBufferFreeSize Description This function retrieves the amount of available space in the output buffer of the specified COM Port Prototype int GetCom8000TxBufferFreeSize int slot int port Arguments slot 0 1 2 3 port 1 8112 I 8142 I 8142i 0 1 1 8114 l 8144 0 1 2 3 Return Values The amount of available space On success 1 The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page63 2 2 13 GetCom8000FifoTriggerLevel Description This function r
57. S7 API Functions Reference Manual version 1 12 Jan 2009 Page177 9 1 2 3 8 T2_CountDownTimerContinue Description Continue the countdowntimer Refer to Sec 9 1 2 3 1 typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype void T2_CountDownTimerContinue COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page178 9 1 2 3 9 T2_CountDownTimerlsTimeUp Description Check the time of countdown is up or not Refer to Sec 9 1 2 3 1 typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype int T2_CountDownTimerlsTimeUp COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value Time isn t up 1 Time is up MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page179 9 1 2 3 10 T2_CountDownTimerGetTimeLeft Description Get remnant time of countdown NormTimeTicks Refer to Sec 9 1 2 3 1 about NormTimeTicks value affects remnant time of countdown If NormTimeticks value still not changing T2_CountDownTimerGetTimeLeft reads the same value continuously typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prot
58. User can call SetUserTimer 1 to set them to use timer 1 Prototype int SetUserTimer int no Arguments num num 0 use timer 0 num 1 use timer 1 Return Value 0 Use timer 0 1 Use timer 1 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page196 10 Files Functions Remark The file system for MiniOS7 supports user s program to read files but not supports user s program to write files 10 1 Disk A and Disk B Flash file system space 1 For 256K type segment 0xC000 0xD000 OxE000 can be used Three segments can be used 2 For 512K type segment 0x8000 0x9000 OxA000 0xBO00 0xC000 0xD000 OxE000 can be used Seven segments can be used 3 The segment 0xF000 is used for MiniOs7 How to divide file system space into diskA and diskB MiniOS7 Utility can divide file system space Three or Seven segments into three parts which are diskA diskB and reserved Refer to http ftp icodas com tw pub cd 8000cd napdos minios7 utility minios7_utility MiniOS7 Disk Information DAR Set Reserved Flash Segments Help Disk A 192 KB H DiskA dike C Reserve 0s MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page197 10 2 Common Functions for all i 7188 i 8000 uPAC 7186 PDS 700 Series 10 2 1 GetFileNo_AB Description define DISKA 0 define DISKB 1 About the diskA or diskB refer to Sec 10 1 Get total nu
59. age82 2 2 30 SetBreakMode8000 Description This function sets the continuous sending of a break signal as either enabled or disabled for the specified COM Port The default mode is disabled Prototype void SetBreakMode8s000 int slot int port int mode Arguments slot 0 1 2 3 port 1 8112 l 8142 I 8142i 0 1 1 8114 l 8144 0 1 2 3 mode Default mode is disabled 1 Enabled 0 Disabled Return Values None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page83 2 2 31 IsDetectBreak8000 Description This function checks whether the specified COM Port has received a break signal Prototype int lsDetectBreak8000 int slot int port Arguments slot 0 1 2 3 port 1 8112 l 8142 I 8142i 0 1 1 8114 1 8144 0 1 2 3 Return Values A break signal is detected o No break signal is detected 1 The slot or port is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page84 2 2 32 SendBreak8000 Description This function sends a continuous break signal to the specified COM Port for a specified period of time timems Prototype void SendBreak8000 int slot int port unsigned timems Arguments slot 0 1 2 3 port 1 8112 I 8142 1 8142i 0 1 I 8114 I 8144 0 1 2 3 timems The period of time to send a continuous break signal time unit is ms Return Values None MinoOS7 API
60. al time clock Prototype int OS7_CloseWriteFile int disk FILE_DATA f_data Arguments disk 0 is diskA Others are diskB f_data Structure pointer variable Points to file header address that the function writes file header data from Return Value 0 On success 2 The argument disk is not the same in the OS7_CloseWriteFile and OS7_OpenWriteFile 3 OS7_OpenWriteFile isn t called before the function is used MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page213 10 3 1 9 OS7_FileDateTimeMode Description The time value setting of file header is affected by this variable OS7_FileDateTimeMode value Description 0 User defines time values of file header 1 Auto write default time value 2006 01 01 12 00 00 2 Auto write time value read from RTC real time clock Prototype extern int OS7_FileDateTimeMode MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page214 10 3 2 CRC16 functions CRC16 formula in MiniOS7 is CRC CCITT 0x1021 x16 x12 x5 1 Initial value of CRC16 is 0 1 It takes much time about CRC16 calculation If CRC16 functions are used in the ISR Interrupt Service Register it would be better not to count data too much to avoid affecting normal operation of system interrupt 2 There are 16 layers in the stack for CRC16_Push CRC16_Pop It means that maximum number of data stored i
61. alues 0 NoError On success 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page19 2 1 13 IsCom Description This function checks whether there is any data in the COM Port input buffer Prototype int IsCom int port Arguments port 0 8 for COM0 COM8 Return Values 1 QueuelsNotEmpty The queue is not empty 0 QueuelsEmpty There is no data in the COM Port input buffer 7 QueueOverflow When the return value is QueueOverflow 7 ReadCom or ClearCom must be called to reset the overflow status MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page20 2 1 14 IsTxBufEmpty Description This function checks if the output buffer of the COM port hardware is empty All data has been sent Prototype int IsTxBufEmpty int port Arguments port 0 8 for COM0O COM8 Return Values 1 Empty 0 Not Empty 1 PortError port is not is valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page21 2 1 15 IsComOutBufEmpty Description This function checks if the output buffer of COM port software is empty Prototype int IsComOutBufEmpty int port Arguments port 0 8 for COM0 COM8 Return Values 1 Empty Not Empty 1 PortError port is not valid 0 8 MiniOS7 API Functions Re
62. an be 300 to 115200 Return Values 0 NoError On success 1 PortError The port is not valid 0 8 13 BaudRateError The Baud Rate is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page37 2 1 29 SetDataFormat Description This function sets the data format for the COM Port Prototype int SetDataFormat int port int databit int parity int stopbit Arguments Am188ES internal UART 16C550 port 0 8 for COM0 COM8 0 8 for COM0 COM8 data 7 8 5 6 7 8 parity 0 None 1 Even 2 Odd 0 None 1 Even 2 Odd 3 MARK always 1 4 SPACE always 0 stop 2 data bit must be 7 bit or 1 1or2 Return Values 0 NoError On success 1 PortError port is not valid 0 8 DataError data is invalid 2 3 ParityError parity is invalid 4 StopError stop is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page38 2 1 30 SendBreak Description This function sends a BREAK signal to the COM Port until the timems has elapsed Prototype int SendBreak int port unsigned timems Arguments port 0 8 for COM0 COMBS timems The time period for sending the break signal time unit is ms Return Values 0 NoError On success 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page39 2 1 3
63. annel is out of range MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page157 9 1 2 1 9 StopWatchContinue Description Continue the StopWatch Refer to TimerOpen TimerClose Prototype int StopWatchContinue int channel Arguments channel 0 7 total 8 channels Return Value 0 NoError On success 15 ChannelError channel is out of range MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page158 9 1 2 1 10 StopWatchReadValue Description Read current StopWatch value the value stands for the time from StopWatchStart StopWatchReset is called to now Refer to TimerOpen TimerClose Prototype int StopWatchReadValue int channel unsigned long value Arguments channel 0 7 total 8 channels value A pointer for the value to be stored Return Value 0 NoError On success 15 ChannelError channel is out of range MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page159 9 1 2 1 11 TimerResetValue Description Reset the value of system timer s count to 0 Refer to TimerOpen TimerClose Prototype void TimerResetValue void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page160 9 1 2 1 12 TimerReadValue Description Read the value of system timer s count The time unit for ticks is 1 ms Calling TimerOpen or T
64. annot be used on MSC VC Please use Linelnput sscanf instead When the functions of this section are used the default format setting for standard I O port is 115200 N 8 1 13 1 Common Functions for all i 7188 i 8000 uPAC 7186 PDS 700 Series 13 1 1 Kbhit Description Check if any data is currently available in the input buffer of standard I O port Note If Installcom 1 is called this function is not used Prototype int Kbhit void Arguments None Return Value 0 No any data in input buffer others There is data in input buffer and the return value is the next data in buffer If the next data is O it returns 1 OxFFFF MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page258 13 1 2 Getch Description Read one character from standard I O port If there is not any data in the input buffer the function waits until standard I O port receives any data Note If Installcom 1 is called this function is not used Prototype int Getch void Arguments None Return Value 0 to 255 On success MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page259 13 1 3 Gets Description Get a string from standard input port Note If Installcom 1 is called this function is not used Prototype int Gets char str Arguments str The buffer which stores the input data Return Value
65. are used T2_UpdateCurrentTimeTicks is value called Note If these functions are used frequently it takes Note The error about much time to read stopwatch or countdown TimeTicks value regularly depends on how long the time of next T2_UpdateCurrentTimeTicks is called in a loop TimerOpen Before other functions TimerOpen and TimerClose TimerOpen and TimerClose TimerClose are used TimerOpen need not to be called need not to be called must be called Finally TimerClose also has to be called to stop using timer functions MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page149 9 1 2 1 First Kind Functions 9 1 2 1 1 TimerOpen Description Start to use timer function Before using Sec 9 1 2 1 timer functions InstallUserTimer and InstallUserTimer1C it must call TimerOpen After TimerOpen is called user can use 8 StopWatchTimer and 8 CountDownTimer and the system timer Then the system timer ISR Interrupt Service Routine increases the value of system timer s count by 1 every 1 ms Prototype int TimerOpen void Arguments None Return Value 0 NoError On success 1 Timer is already opend See also TimerClose MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page150 9 1 2 1 2 TimerClose Description Stop to use timer function If the program has called TimerOpen it must call TimerClose before exiting Otherwise the system must malfun
66. at have 1 32 output points These functions sets the LED display value automatically Prototype void DO_ amp int slot unsigned char cdata void DO_16 int slot unsigned int cdata void DO_32 int slot unsigned long cdata Arguments slot For 4 slots 0 3 For 8 slots 0 7 cdata Each bit for one output point 1 for Active 0 for inactive If the output is Open Collector active means the transister is turn on If the output is Relay active means NO Normal Open pin connect to COM pin Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page238 12 3 1 2 DI Functions Description Read the input value of l 8000 Digital input module DI_8 for the D I modules that have 1 8 points DI_16 for the D I modules that have 1 16 points DI_32 for the D I modules that have 1 32 points Prototype unsigned char DI_ 8 int slot unsigned int DI_16 int slot unsigned long int DI_32 int slot Arguments slot For 4 slots 0 3 For 8 slots 0 7 Return Value Each bit for one input 1 for active O for inactive MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page239 12 3 1 3 DIO Functions Description Set the output value of l 8000 Digital output module DIO_DO_8 amp for the DI8_DO8 or DI4 D04 modules DIO_DO_16 for the DI16_DO16 modules These functions sets the LED display value automatically Prototype vo
67. bus pins please refer to I O Expansion Bus for 7188X 7188E User s Manual Prototype void SetDio4Dir int dir void SetDio9Dir int dir void SetDio14Dir int dir void SetTiODir int dir void SetTi1Dir int dir void SetToODir int dir void SetTo1Dir int dir Arguments dir 0 Set the PIO pin to output mode 1 Set the PIO pin to input with pull high for some pin is pull low 2 Set the PIO pin to Input mode without pull high low TO_0 amp TO_1 3 Set the PIO pin to normal mode Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page251 12 4 6 Get PIO Status Functions Description When the PIO pins of CPU are set to output mode it can get current output status from those functions When the PIO pins of CPU are set to intput mode it can get current intput status from those functions These PIO pins connect to I O expansion bus About the I O expansion bus pins please refer to I O Expansion Bus for 7188X 7188E User s Manual Prototype int GetDio4 void int GetDio9 void int GetDio14 void int GetTi0 void int GetToO void int GetTi1 void int GetTo1 void Arguments None Return Value 0 Status is low others Status is high MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page252 12 4 7 Set PIO High Functions Description When the PIO pins of CPU are set to output mode these functions are cal
68. ction Prototype int TimerClose void Arguments None Return Value Always return NoError MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page151 9 1 2 1 3 CountDownTimerStart Description Start to use CountDownTimer Refer to TimerOpen TimerClose Prototype int CountDownTimerStart int channel unsigned long count Arguments channel 0 7 total 8 channels count The countdown time Return Values 0 NoError On success 15 ChannelError channel is out of range MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page152 9 1 2 1 4 CountDownTimerReadValue Description Read the current value of CountDownTimer Refer to TimerOpen TimerClose Prototype int CountDownTimerReadValue int channel unsigned long value Arguments channel 0 7 total 8 channels value Store current value of CountDownTimer When the value is 0 time is up Return Values 0 NoError On success 15 ChannelError channel is out of range MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page153 9 1 2 1 5 StopWatchReset Description Reset the StopWatch value to 0 Refer to TimerOpen TimerClose Prototype int StopWatchReset int channel Arguments channel 0 7 total 8 channels Return Value 0 NoError On success 15 ChannelError channel is
69. culation of following program segment CRC16_AddDataN data data_len add data crc16_n CRC16_Read read current CRC16 value and store it to use next time MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page216 CRC16_Pop restore old CRC16 value I Annotate MiniOS7 load is an example ICPDAS modules based on MiniOS7 receive a file from PC whose unit is packet They calculate CRC16 value CRC_1 of each packet and compare CRC16 value recorded in the packet with CRC_1 every time File header stores CRC16 value of whole file which is calculated when modules receive packets every time There are two CRC16 operations to calculate at the same time in this situation MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page217 10 3 2 1 CRC16_MakeTable Description Get a buffer from system memory and build a table for CRC16 This function must be called before CRC16_AddData CRC16_AddDataN_C and CRC16_AddDataN are used Prototype int CRC16_MakeTable void Arguments None Return Value 0 On success 1_ Retrieving memory fail MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page218 10 3 2 2 CRC16_Push Description Push CRC16 value into stack There are 16 layers in the stack Prototype int CRC16_Push void Arguments None Return Value 0 On success 1 Stack is overflow MinoOS7 API Functions Reference Man
70. duleName i else Print Slot d without any module n r i Prototype extern unsigned char far const ModuleType extern unsigned char far const ModuleName extern unsigned char far const ModuleFullName MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page284 14 3 2 ChangeToSlot Description Choose which slot can communicate with COMO Prototype void ChangeToSlot int slot Arguments slot For 4 slots 84XX 0 3 For 8 slots 88XX 0 7 Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page285 14 3 3 GetNetld Description There is a switch which is used to set ID of the module for 8000 series User s program can use GetNetld to read the value Prototype int GetNetld void Arguments None Return Value 0 255 ERAIN vae MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page286 14 3 4 Description GetNumberOfSlot It is used to check the system is 84xx or 88xx In I 8000 series I 84xx have 4 slots I 88xx have 8 slots Prototype int GetNumberOfSlot void Arguments None Return Value 4 For 84xx 8 For 88xx MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page287 14 3 5 Description NumberOfSlot Get the number of slot to know which type of backplane is the type of 4 slots or 8 slots After GetNumberOfSlot is called it sets the va
71. e function and the second type function must set different timer when they are used together MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page181 9 1 3 1 InstallUserTimer Description Install user s timer function User s timer function is called every 1 ms Refer to Sec 9 1 2 1 1 TimerOpen Sec 9 1 2 1 2 TimerClose Prototype void InstallUserTimer void fun void Arguments fun The user s function pointer The function cannot use input argument and cannot return value Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page182 9 1 3 2 InstallUserTimer1C Description Install user s timer function on interrupt Ox1c Refer to Sec 9 1 2 1 1 TimerOpen Sec 9 1 2 1 2 TimerClose System timer calls int Ox1c every 55 ms Prototype void InstallUserTimer1C void fun void Arguments fun The user s function pointer The function cannot use input argument and cannot return value Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page183 9 1 3 3 InstallUserTimerFunction_us Description Install user s timer function Time unit is 0 1 us Default timer is timer 0 For example If user wants timer generates interrupt every 0 5ms 500 us 5000 0 1us That is to say system calls your function once every 0 5 ms Just use Prototype int InstallUserTimerFunction_us unsigned time void fun v
72. e functions XEE_xxxxxxx can be used after XEE_InitByName or XEE_Init is called XEE_InitByName is the same as XEE_Init except for the input parameters The user just chooses either XEE_Init or XEE_InitByName to initialize the EEPROM Prototype int XEE_InitByName int Xboard Arguments Xboard define _X201_ 201 define _X202_ 202 define _X203_ 203 define _X205_ 205 define _X206_ 206 define X300_ 300 define X301_ 301 define X302_ 302 define X303_ 303 define X304_ 304 define X305 305 define X306 306 define X308 308 define X309 309 define X310_ 310 define _X314_ 314 The new value can be added at any time Refer to the xxxx h file for example 7188e h to get the latest value Return Values 0 On success 1 The board is unsupported MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page103 3 1 10 XEE_WriteEnable i 7188 i 7188XA i 752N i 7188EA i 7188EN i 8000 i 7188XB i 7188XC i 7 188EX uPAC 7186EX PDS 700 series series Support Y Y This module is supported Description This function set the EEPROM 24LC16 on the X board to write enabled mode Prototype void XEE_WriteEnable void Arguments None Return Values None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page104 3 1 11 XEE_WriteProtect i 7 188 i 7188XA i 752N i 7 188EA i 7 1 88EN i 8000 i 7188XB i 7188XC i 7 188EX
73. e is 9600bps Prototype int _SetBaudrate int slot int port unsigned long baud Arguments slot 0 1 2 3 port 1 8112 I 8142 l 8142i 0 1 1 8114 l 8144 0 1 2 3 baud 1 8112 l 8114 15 to 115200 bps I 8142 I 8142i l 8144 15 to 921600 bps Return Values 0 NoError On success 1 slot or port number is invalid 16 baud value is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page56 2 2 6 _SetDataFormat Description This function sets the data format for the specified COM Port After calling InstallCom8000 the default values as follows data bit 8 parity bit none stop bit 1 Prototype int _SetDataFormat int slot int port int data int parity int stop Arguments slot 0 1 2 3 port I 8112 I 8142 I 8142i 0 1 I 81 14 l 8144 0 1 2 3 data 5 6 7 8 parity 0 None 1 Even 2 Odd 3 mark always 1 4 space always 0 stop 1 2 Return Values 0 On success 1 The slot or port is invalid 2 data value is not 5 6 7 8 3 parity value is not 0 1 2 3 4 4 stop value is not 1 2 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page57 2 2 7 ClearCom8s000 Description This function clears all the data from the input buffer of the specified COM Port Prototype int ClearCom8000O int slot int port Arguments slot 0 1 2 3 port 1
74. e maximun write size is 16 bytes and must be written to the same block 1 An additional limitation is that only the lowest 4 bits of the address can be changed The value variation 0 gt 1 gt 2 gt 3 gt 4 gt 5 gt 6 gt 7 gt 8 gt 9 gt 0xA gt 0xB gt 0xC gt 0xD gt 0xE gt 0xF gt 0 2 The highest 4 bits of the address can t be changed For example XEE_MultiWrite 1 21 16 ABCDEFGHIJKLMNOP 16 bytes A P write to the EEPROM from address 21 0x15 They should end at 36 0x24 But according to this limitation it returns to address 16 0x10 when data is written to address 1F The data L P are written from address 0x10 to 0x14 3 It is recommended that Addr uses 0x00 0x10 0x20 0xF0 Prototype int XEE_MultiWrite int Block int Addr int num char Data Arguments Block 0 to 7 Total is 8 blocks Addr 0 to 255 Each block is 256 bytes num 1 to 16 Data The starting address of the buffer where the data will be written into EEPROM Return Values 0 NoError On success MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page107 The EEPROM is busy the Block or Addr is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page108 4 Flash Memory Functions Remark 1 There are two size 256K bytes and 512K bytes for the Flash Memory used on i 7188 i 8000 series The size of flash memory on uPAC 7186 PDS 700 serie
75. ection to be controlled by the software I 7522 I 7523 modules are the l 7521 with a daughter board X501 X502 that adds 1 or 2 additional RS 232 ports COM3 4 I 7522A I 7524 7527 modules are the i 7188XB with a daughter board X507 X505 X506 that adds an additional RS 422 ports and an additional 3 or 6 RS 232 ports i 7188EX i 7188EA i 7188EN By default i 7188E series modules contain two COM Ports except for i 7188E1 COM1 is RS 232 and COM2 is RS 485 COM1 is the standard I O port for the MiniOS7 and is used to receive commands and download files The two COM PORTS use the internal UART of the CPU Am188ES and are not compatible with the 16C550 on the hardware level A built in Self Tuner is included in the RS 485 of i 7188E series modules so there is no need for the RS 485 data direction to be controlled by the software i 8000 series i 8000 series support up to 5 COM ports COM Port Serial protocol UART Descriptions COMO RS 232 CPU internal uart For 87K modules The default standard I O port for the MiniOS7 and is used to receive commands and download files User COM1 RS 232 CPU internal uart programs can also use COM1 to connect to other RS 232 devices COM2 RS 485 16C550 The maximun Baud Rate is 921000 bps MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Pages COM4 RS 232 16C550 RS 232 is 9 wire i 7188 i 7188XA
76. ed and the system Timer ISR Interrupt Service Routine refresh it When user s program calls EnableWDT the system timer ISR stops to refresh WDT and user s program must do it by call RefreshWDT Otherwise the system is reset by WDT The timeout period of WDT is 0 8 seconds Prototype void EnableWDT void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page146 9 1 1 2 DisableWDT Description After DisableWDT is called the system timer ISR Interrupt Service Routine refreshes WDT so user s program need not to call RefreshWDT Prototype void DisableWDT void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page147 9 1 1 3 RefreshWDT Description After EnableWDT is called the system Timer ISR Interrupt Service Routine does not refresh WDT so user s program must call RefreshWDT to refresh WDT Prototype void RefreshWDT void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page148 9 1 2 CountDownTimer and StopWatch Functions There are three kinds of countdowntimer and stopwatch functions First Kind Second Kind Third Kind aii Functions Functions Functions Items Channel Max 8 No channel number No channel number limitation number limitation Read No Read it every time when Read it only when TimeTicks these functions
77. epresents a channel Total is 16 bits 0 for DO mode 1 for DI mode MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page242 12 3 1 5 2 UDIO_WriteConfig_16 Description For universal DI DO such as 8050 Set respective setting mode of 16 channels Prototype void UDIO_WriteConfig_16 int slot unsigned config Arguments slot For 4 slots 0 3 For 8 slots 0 7 config Each bit represents a channel Total is 16 bits 0 for DO mode 1 for DI mode Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page243 12 3 2 i 87K series MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page244 12 4 10 Expansion Bus and CPU Pins Remark 1 User can use those function to control 32 PIO pins of CPU Am188ES or each pin of I O expansion bus 2 If the user wants to design new IO expansion board using prototype board like X000 these functions in this section helps you to develop your own expansion board 3 I O expansion bus refers to CD Napdos 7188XABC Xboard Document or http ftp icpdas com pub cd 8000cd napdos 7188xabc xboard document MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page245 12 4 1 Respective Functions Table Functions i 7188 i 7188XA i 7188XB i 7 188XC i 752N i 7188EX i 7188EA i 7188EN PDS 700 series UPAC 7186EX uPAC 7186EX FD uPAC 7186EX FM UPAC 7186EX S
78. er By default use timer0 unit ms ms o oms ooms Timer Change No Yes note Yes note Yes note note SetDelayTimer in Sec 9 2 2 TimeTicks GetTimeTicks GetTimeTicks_ ISR results in error Source ade long st long st long st comparison st TimeTicks _asm cli _asm pushf st TimeTicks _asm cli f st TimeTicks _asm sti _asm popf 9 1 4 1 DelayMs Description Delay some time interval the time unit is ms CPU doesn t do anything but it still can accept interrupt signal during time interval of delay There are three timers in CPU DelayMs uses the timer2 to do the delay operation Prototype void DelayMs unsigned t Arguments t the delay time Unit is ms Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page187 9 1 4 2 Delay Description Delay some time interval the time unit is ms There are three timers in CPU Delay uses the timer0 to do the delay operation If user wants to change the timer for Delay please refer to SetDelayTimer When InstallUserTimerFunction_us InstallUserTimerFunction_ms and Delay are used together user has to set different timer for them If not they clash with each other The SetDelayTimer and SetUserTimer can set timerO or timer1 to be used Prototype void Delay unsigned ms Arguments ms the delay time Unit is ms Return Value None MiniOS7 API Functions Reference Manual version
79. er Level Error MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Paged1 2 2 For I 8142_1 8142i_1 8144_1 8144i_1 8112_1 8114 Remarks I 8142 I 8142i I 8144 l 8144i I 8112 I 8114 can only use the following four slots slot 0 slot 3 2 2 1 SetinBufSize Description This function sets the size of the software s input buffer for each port of all slots The size for each port is the same The input data is stored in the input buffer After SetInBufSlze is used InstallCom8000 must be called Now the size of the software s input buffer is really set Prototype int SetInBufSIze int size Arguments size 1 to 32767 The Default value is 1024 Return Value 0 NoError On success MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page52 2 2 2 SetOutBufSize Description This function sets the size of the software s output buffer for each port of all slots The size for each port is the same The output data is stored in the output buffer After SetOutBufSlze is used InstallCom8000 must be called Now the size of the software s output buffer is really set Prototype int SetOutBufSlze int size Arguments size 1 to 32767 The default value is 1024 Return Value 0 NoError On success MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page53 2 2 3 InstallCom8000
80. et the weekday typedef struct int year char month day weekday char hour minute sec TIME_DATE Prototype int SetTimeDate TIME DATE timedate Arguments timedate structure variable timedate gt year 2000 2080 timedate gt month 1 12 timedate gt day 1 31 timedate gt hour 0 23 timedate gt minute 0 59 timedate gt sec 0 59 Return Values 0 NoError On success 18 DateError Either year month or day value is invalid 19 TimeError Either hour minute or sec value is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page119 5 1 4 GetTimeDate Description Get the system time and date to the RTC of the module typedef struct int year char month day weekday char hour minute sec TIME_DATE Prototype void GetTimeDate TIME_DATE timedate Arguments timedate structure variable timedate gt year 2000 2080 timedate gt month 1 12 timedate gt day 1 31 timedate gt hour 0 23 timedate gt minute 0 59 timedate gt sec 0 59 timedate gt weekday 0 6 0 is Sunday 6 is Saturday Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page120 SRAM Functions Remark These functions are for 8256 8512 modules For S256 2048 blocks every block has 128 bytes Total size is 256K bytes For 512 4096 blocks every block has 128 byte
81. et5DigitLedTestMode int mode Arguments mode 0 for normal mode 1 for the test mode On test mode all segment turn on and use the largest intensity Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page138 7 1 8 Set5DigitLedintensity Description Set the scan intensity of LED segments the default value 7 For l 8000 the default value is 3 If user feels that intensity is too dark it can be set to higher value Higher value uses more power Prototype void pascal Set5DigitLedIntensity int mode Arguments mode 0 to 15 0 represents the lowest intensity 15 represents the highest intensity Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page139 8 LED Functions 8 1 Common Functions For all i 7188 i 8000 uPAC 7186 PDS 700 series 8 1 1 LedOn Description Turn on the red LED Prototype void LedOn void Arguments None Return Value None LED is here The LED location is the same for 1 7188 HWPAC 7186 PDS 700 series LED is here The LED location is the same for i 8000 series MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page140 8 1 2 LedOff Description Turn off the red LED Prototype void LedOff void Arguments None Return Value None LED is here The LED location is the same for 1 7 188 HPAC 7186 PDS 700 series LED is here The LED locatio
82. etCtsControlMode if there is a CTS pin for the COM Port Description This function sets the flow control RTS CTS for the COM Port The default mode is FLOW_CONTROL_DISABLE The mode define FLOW_CONTROL_DISABLE define FLOW_CONTROL_ENABLE define FLOW_CONTROL_AUTO_BY_HW define FLOW_CONTROL_AUTO_BY_SW Prototype definitions are as follows int SetCtsControlMode int port int mode Arguments port 0 8 for COM0O COM8 mode 1 mode FLOW_CONTROL_DISABLE Either SetCtsControlMode port FLOW_CONTROL_DISABLE or SetRtsControlMode port FLOW_CONTROL_DISABLE is set and the hardware flow control will be disabled 2 mode FLOW_CONTROL_ENABLE Enables the RTS CTS software flow control but the active or inactive status of the RTS pin must be controlled by calling the SetRtsActive or SetRtsInactive function to complete the RTS CTS software flow control 3 mode FLOW_CONTROL_AUTO_BY_HW Either SetCtsControlMode port FLOW_CONTROL_AUTO_BY_HW or SetRtsControlMode port FLOW_CONTROL_AUTO_BY_HW is set and the automatic hardware flow control will be enabled 4 mode FLOW_CONTROL_AUTO_BY_SW Both SetRtsControlMode port FLOW_CONTROL_AUTO_BY_SW and SetCtsControlMode port MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page30 FLOW_CONTROL_AUTO_BY_SW are set and the automatic RTS CTS software flow control will be enabled Return Values 0 NoError On success
83. etrieves the receiver FIFO trigger level bytes value for the specified COM Port The default trigger level value is 8 bytes Prototype int GetCom8000FifoTriggerLevel int slot int port Arguments slot 0 1 2 3 port 1 8112 I 8142 1 8142i 0 1 1 8114 I 8144 0 1 2 3 Return Values 1 4 8 14 On success 1 The slot or port is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page64 2 2 14 GetCurMsr8000 Description This function retrieves the content of the Modem Status Register MSR for the specified COM Port when an MSR interrupt has recently occured The definition for each bit is as follows define MSR_dCTS 0x01 define MSR_dDSR 0x02 define MSR_TERI 0x04 define _MSR_dDCD 0x08 define MSR_CTS 0x10 define MSR_DSR 0x20 define _MSR_RI 0x40 define MSR_DCD 0x80 Prototype int GetCurMsr8000 int slot int port Arguments 0 1 2 3 port 8112 I 8142 8142i 0 1 1 8114 I 8144 0 1 2 3 Return Values The 8 bit status of the MSR On success 1 The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page65 2 2 15 GetCom8000_MSR Description This function retrieves the current content of the Modem Status Register MSR for the specified COM Port The definition for each bit is as follows define MSR_dCTS 0x01 define MSR_dDSR 0x02 define MSR_TERI 0x04 define MSR_dDCD 0x08
84. ference Manual version 1 12 Jan 2009 Page22 2 1 16 IsDetectBreak Description This function checks if the COM port has received a BREAK signal Prototype int IsDetectBreak int port Arguments port 0 8 for COM0O COM8 Return Values 1 A break signal was detected 0 No signal detected 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page23 2 1 17 printCom Description This function allows data to be output from the COM Port in the same way as the printf function in the C library Prototype int printCom int port char fmt Arguments port 0 8 for COM0 COM8 fmt Please refer to library printf in the C Return Values Non negative The number of bytes sent to the COM Port 1 PortError port is not valid 0 8 EOF See the C library MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page24 2 1 18 RestoreCom Description If the program calls InstallCom RestoreCom must be called to restore the COM Port setting before exiting the program Prototype int RestoreCom int port Arguments port 0 only for i 8000 series modules 1 8 for i 7188 i 8000 uPAC 7186 PDS 700 series modules Return Values 0 NoError On success 1 PortError port is not valid 0 8 MinoOS7 API Functions Reference Manual version 1 12 Jan
85. for the COM Port Description This function reads the current state of the CTS pin Prototype extern int CurCTS_1 extern int CurCTS_ 3 extern int CurCTS_4 extern int CurCTS_5 Arguments CurCTS_1 1 The CTS pin is active low CurCTS_1 0 The CTS pin is inactive high MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page10 2 1 4 CurRTS_x COM Port i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7188EA i 7 188EN uPAC 7186EX series PDS 700 series i 8000 COM 0 COM 1 lt Y COM 2 COM 3 COM 4 lt lt COM 5 lt lt lt lt lt lt COM 6 COM 7 COM 8 Y The COM Port can use CurRTS x if there is a RTS pin for the COM Port Description This function reads the current state of the RTS pin Prototype extern int CurRTS_1 extern int CurRTS_ 3 extern int CurRTS_4 extern int CurRTS_5 Arguments CurRTS_1 1 The RTS pin is active low CurRTS_1 0 The RTS pin is inactive high MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page11 2 1 5 fCtsControlMode_x COM Port i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7188EA i 7 188EN uPAC 7186EX series PDS 700 series i 8000 COM 0 COM 1 lt Y COM 2 COM 3 COM 4 lt lt COM 5 lt lt lt lt lt lt COM
86. ftp icodas com tw pub cd 8000cd napdos 8000 841x881x demo Lib MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page3 For i 7188 Supports a single memory model 1 7188L LIB is for LARGE Memory MODEL TC BC MSC MSVC All function declarations are included in i7188 h file so the following line should be added to the beginning of the program include i7188 h 7188L LIB is located in the following directory Companion CD Napdos 7188 MINIOS7 DEMO ib or http ftp icodas com tw pub cd 8000cd napdos 7188 minios7 demo lib NOTE nitLib must be called before any other functions are used in the library InitLib described is in Sec 14 Others MISC Functions MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page4 2 COM Ports Functions The COM Port hardware i 7 188XB i 7188XC i 752N By default i 7188X i 752N series modules contain two COM Ports COM1 is both RS 232 and RS 485 use diffrenet pins to select RS 232 or RS 485 COM2 is RS 485 only COM1 is the standard I O port for the MiniOS7 and is used to receive commands and download files User programs can also use COM1 to connect to other RS 232 RS 485 devices The two COM PORTS use the internal UART of the CPU Am188ES and are not compatible with 16C550 on hardware level A built in Self Tuner is included in the RS 485 of i 7188X i 752N series modules so there is no need for the RS 485 data dir
87. i 7188 i 7188XA support 4 COM ports COM Port Serial protocol UART Descriptions RS 232 is 9 wire and uses jumper to select RS 232 COM1 RS 232 RS 485 16C550 or RS 485 A built in Self Tuner is included on the RS 485 of i 7188XA but not in the i 7188 A built in Self Tuner is included on the RS 485 of i COM2 RS 485 16C550 7188XA but not in the i 7188 COM3 RS 232 CPU internal uart The default standard I O port for the MiniOS7 and is used to receive commands and download files User COM4 RS 232 CPU internal uart programs can also use COM4 to connect to other RS 232 devices uPAC 7186EX series PDS 700 series 1 By default uPAC 7186EX PDS 700 series modules contain two COM Ports 2 COM1 is the standard I O port for the MiniOS7 and is used to receive commands and download files 3 The two COM PORTS use the internal UART of the CPU 80186 and are not compatible with the 16C550 on the hardware level 4 A built in Self Tuner is included in the RS 485 ofuPAC 7186EX PDS 700 series modules so there is no need for the RS 485 data direction to be controlled by the software MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page6 2 1 Common Functions Variables for all i 7188 i 8000 uPAC 7186 PDS 700 Series Modules MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page7 2 1 1 InstallCom COM Port re FARBER
88. i 7188XA i 752N i 7 188EA i 7 1 88EN i 8000 i 7188XB i 7188XC i 7 188EX UPAC 7186EX PDS 700 series series Support Y Y This module is supported Description This function initializes the parameters for the EEPROM 24LC16 on an X board X20x or X3xx The functions XEE_xxxxxxx can be used after XEE_Init or XEE_InitByName is called Prototype int XEE_Init int clk_pin int sda_pin int wp_pin int need_pullhigh Arguments clk_pin The PIO pin number of the CPU that is connected to the CLK pin of the 24LC16 sda_pin The PIO pin number of the CPU that is connected to the SDA pin of the 24LC16 wp_pin The PIO pin number of the CPU that is connected to the WP pin of the 24LC16 need_pullhigh If the sda_pin is set to input mode gt 0 Pullhigh resistance is not needed 1 Pullhigh resistance is needed Return Values 0 NoError On success 25 XEECLKError clk_pin value is invalid 26 XEESDAError sda_pin value is invalid 27 XEEWPError wp_pin value is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page102 3 1 9 XEE_InitByName i 7188 i 7188XA i 752N i 7 188EA i 7 1 88EN i 8000 i 7188XB i 7188XC i 7 188EX uPAC 7186EX PDS 700 series series Support Y Y This module is supported Description This function initializes the parameters for the EEPROM 24LC16 on an X board Th
89. id Arguments None Return Values 0 255 The data read 6 QueueEmpty The queue is empty MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page50 2 1 42 COM Port i 7188 i 7188XA i 7188XB SetComFifoTriggerLevel i 7188XC i 752N i 7188EX i 7188EN uPAC 7186EX series PDS 700 series i 7188EA i 8000 COM 0 COM 1 lt lt COM 2 lt lt COM 3 COM 4 lt lt lt COM 5 lt lt COM 6 COM 7 lt lt lt lt lt COM 8 Y lt lt Y The COM Port can use SetComFifoTriggerLevel function Description Set 16550 s FIFO trigger level for each COM port The trigger level refers to the number of characters required to be in the UART s receive buffer before an interrupt is generated it will also generate an interrupt if the number of characters of the buffer doesn t reach the trigger level but serial data flow has stopped and the system wait for a little time without receiving any data so the system doesn t always have to wait until the trigger level is reached Prototype int SetComFifoTriggerLevel int port int level Arguments port Refer to that table above level 1 4 8 or 14 Default value is 8 Return Value 0 NoError On success 1 PortError Port error 17 TriggerLevelError Trigg
90. id DIO_DO_ amp int slot unsigned char cdata void DIO_DO_16 int slot unsigned cdata Arguments slot For 4 slots 0 3 For 8 slots 0 7 cdata Each bit for one output point 1 for Active 0 for inactive If the output is Open Collector active means the transister is turn on If the output is Relay active means NO Normal Open pin connect to COM pin Return Value None Note Read input value on DI8_DO8 DI4_DO4 DI16_DO16 modules is to use Sec 12 3 1 2 functions MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page240 12 3 1 4 Al_AO Functions g r r We provide extra functions and library for Al or AO modules like I 8017H I 8024 About Al AO modules information CD napdos dcon io_module 8k aio index htm or http Awww icpdas com products PAC i 8000 8000 IO modules htm Functions description is in header file like 8017h h The head file locations are as follows CD Napdos 8000 841x881x demo Lib or http ftp icodas com pub cd 8000cd napdos 8000 841x881x demo Lib MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page241 12 3 1 5 Universal DIO Functions 12 3 1 5 1 UDIO_ReadConfig_16 Description For universal DI DO such as 8050 Get respective setting mode of 16 channels Prototype unsigned UDIO_ReadConfig_16 int slot Arguments slot For 4 slots 0 3 For 8 slots 0 7 Return Value 0x00 to OxFF Each bit r
91. igned int seg unsigned int offset Arguments seg 0 to 65535 Oxffff offset 0 to 65535 Oxffff Return Value FlashReadB only returns the value in the seg offset address MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page112 4 1 5 FlashReadl Description Reads data from the FLASH memory where the size is that of the unsigned int A far pointer can be used to access the data on the Flash memory directly The code is int far IntData dataint IntData int far MK_FP segment offset dataint IntData Prototype unsigned FlashReadI unsigned int seg unsigned int offset Arguments seg 0 to 65535 Oxffff offset 0 to 65535 Oxffff Return Value FlashReadI only returns the value in the seg offset address MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page113 4 1 6 FlashReadL Description Reads data from the FLASH memory where the size is that of the unsigned long A far pointer can also be used to access the data on the Flash memory directly The code is long far LongData datalong LongData long far MK_FP segment offset datalong LongData Prototype unsigned long FlashReadL unsigned int seg unsigned int offset Arguments seg 0 to 65535 Oxffff offset 0 to 65535 Oxffff Return Value FlashReadL only returns the value in the seg offset address
92. igned long address unsigned num unsigned char data Arguments address 0 Ox3FFFF for S256 0 Ox7FFFF for 512 num The byte number to write data The buffer address to store data Return Values 0 NoError Always return 0 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page128 7 5DigitLed Functions i 7188 uPAC 7186 PDS 700 series 6 6 6 gt Lol m 4 ok fh hb gt gt gt 2 4 2 2 2 4 2 4 3 7 J 7 3 7 3 7 D E D D D 5DigitLed number is the leftmost is position 1 and the rightmost is position 5 i 8000 series fol hal ee dak hod gt teh Clk iee ak ola 3 7 3 e7 3 J 3 eT 5DigitLed number is the leftmost is position 1 and the rightmost is position 5 1 2 5DigitLed for i 7188 uPAC 7186 PDS 700 series is optional but for l 8000 series is built in It is five 7 seg LED with the point on the left bottom side 5DigitLed is the default message display device for these modules User can use it to show the message number address time and so on The Red Led lights after the module is power on User s program also can control it MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page129 7 1 Common Functions for all i 7188 i 8000 uPAC 7186 PDS 700 Series 7 1 1 Init5DigitLed Description Initialize 5 digits seven segment L
93. imerReset resets the valuse to 0 Refer to TimerOpen TimerClose Prototype unsigned long TimerReadValue void Arguments None Return Value The value is a period of time since TimerOpen or TimerReset is called to now MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page161 9 1 2 2 Second Kind Functions 9 1 2 2 1 T_StopWatchStart Description Start to use a stopwatch record the current TimeTicks value sw gt ulStart TimeTicks and set sw gt uMode 1 The sw gt ulStart is the start value of stopwatch typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype void T_StopWatchStart STOPWATCH sw Arguments sw Structure pointer variable Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page162 9 1 2 2 2 T_ StopWatchGetTime Description Read current stopwatch value typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype ulong T_StopWatchGetTime STOPWATCH sw Arguments sw Structure pointer variable Return Value Non negative Current stopwatch value MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page163 9 1 2 2 3 T_ StopWatchPause Description Pause the stopwatch Record current TimeTicks value to sw gt ulPauseTime sw gt ulPauseTime TimeTicks a
94. iteProtect is called to set the EEPROM to write protect mode 3 1 Common Variables Functions for all i 7188 i 8000 uPAC 7186 PDS 700 Series Modules 3 1 1 EepType Description This function reads the type of EEPROM contained in the module Prototype extern int EepType Return Values 16 EEPROM is 24LC16 Size is 2k bytes 128 EEPROM is 24LC128 Size is 16k bytes MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page95 3 1 2 EE _WriteEnable Description This function sets the EEPROM to write enabled mode Prototype void EE_WriteEnable void Arguments None Return Values None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page96 3 1 3 EE _WriteProtect Description This function sets the EEPROM to write protected mode Prototype void EE_WriteProtect void Arguments None Return Values None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page97 3 1 4 EE_ MultiRead Description This function reads multiple bytes of data from the EEPROM Prototype int EE_MultiRead int StartBlock unsigned StartAddr int num char databuf Arguments StartBlock 0 to block number 1 Now block number is 8 or 64 blocks StartAddr 0 to 255 Each block is 256 bytes num 1 to 2048 The data length databuf The address where the data is stored Return Values 0 NoError On success
95. kA 1 is diskB num The file index The first file is index 0 Return Value Start address of the file On success NULL On fail MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page202 10 2 6 GetFilePositionByName_AB Description define DISKA 0 define DISKB 1 About the diskA or diskB refer to Sec 10 1 Use file name to get file start position on Flash Memory Prototype char far GetFilePositionByName_AB int disk char fname Arguments disk 0 is diskA 1 is diskB fname file name Return Value Start address of the file On success NULL On fail MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page203 10 2 7 ReadSizeAB Description Read diskA and diskB information and then write data to SIZE_AB structure DiskAStartSeg and DiskBStartSeg About the diskA or diskB refer to Sec 10 1 typedef struct unsigned sizeA 3 unsigned sizeB 3 unsigned sizeC 3 unsigned sum 7 SIZE_AB Prototype void ReadSizeAB void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page204 10 3 Respective Functions Variables for all i 7188 i 8000 WPAC 7186 PDS 700 Series 10 3 1 Respective Functions Variables Table Variables i 7188 i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7 188EA i 7188EN i 8000 PDS 700 series uPAC 7186EX UPAC 7186
96. l number Return Value 0 On success 1 Cannot find the hardware IC 2 Serial number CRC check error The hardware IC is abnormal NOTE Data source Security SystemSerialNumber Read data from RAM Normal GetSerialNumber Read data from IC High MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page281 14 2 4 GetComportNumber Description Get COM port number on a module Prototype int GetComportNumber void Arguments None Return Value Non negative COM port number MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page282 14 3 Only For i 8000 Remark 1 To communicate with add on 87K modules one must use COMO to send receive command and also use ChangeToSlot to select one slot to connect to COMO Every l 8000 module can set its system ID the system ID can be read by function GetNetld There are two kinds of backplane for I 8000 one is 4 slots and the other is 8 slots Program can call GetNumberOfSlot to get the slot number 4 There are three system LEDs for l 8000 L1 L2 L3 SetLedL1 SetLedL2 SetLedL3 can be used to control these LEDs Sec 8 2 3 5 Terer are four system key for l 8000 SET MODE UP DOWN IsSytemKey can be used to check if any key is available use GetSytemKey to read the system key use ClearSystemKey to clear all system key input on the buffer MinoOS7
97. led and set these pins to output High These PIO pins connect to I O expansion bus About the I O expansion bus pins please refer to I O Expansion Bus for 7188X 7188E User s Manual Prototype void SetDio4High void void SetDio9High void void SetDio14High void void SetTiOHigh void void SetToOHigh void void SetTi1High void void SetTo1High void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page253 12 4 8 Set PIO Low Functions Description When the PIO pins of CPU are set to output mode these functions are called and set these pins to output Low These PIO pins connect to I O expansion bus About the I O expansion bus pins please refer to I O Expansion Bus for 7188X 7188E User s Manual Prototype void SetDio4Low void void SetDio9Low void void SetDio14Low void void SetTiOLow void void SetToOLow void void SetTi1Low void void SetTo1Low void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page254 12 4 9 ClockHigh Description Set PIO pin 26th of CPU to output high The PIO pin 26th connects to SCLK pin of I O expansion bus About the I O expansion bus pins please refer to I O Expansion Bus for 7188X 7188E User s Manual Prototype void ClockHigh void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page255
98. lue into NumberOfSlot So it has to call GetNumberOfSlot and then NumberOfSlot is able to be used Prototype extern int NumberOfSlot Return Value 4 For 84xx 8 For 88xx MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page288 14 3 6 SlotAddr Description SlotO Slot1 Slot2 Slot3 Slot4 Slot5 Slot6 Slot7 0x80 Oxa0 OxcO OxeO 0x140 0x160 0x180 0x1a0 Prototype extern int SlotAddr 8 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page289 14 3 7 GetSlotint Description On I 88xx series there are 8 slots The last 4 slots share the same interrupt signal it must call GetSlotint to check which slot generates the interrupt signal Prototype int GetSlotInt void Arguments None Return Value 4to7 The slot that generates the interrupt signal MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page290 14 3 8 CirSlotint Description 88xx series has 8 slots for add on modules The last 4 slots share the same interrupt signal Calling ClrSlotInt can mask the interrupt signal of that slot Prototype void ClrSlotint int mask Arguments mask bit O 3 represent slot 4 7 One bit mask one slot 1 for mask 0 for unmask Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page291 14 3 9 CirAllSlotint Description 88xx se
99. mand to 7000 series or i 87K If checksum is enabled the function adds 2 bytes as checksum on the end of command Prototype int SendCmdTo7000 int iPort unsigned char cCmd int iChksum Arguments iPort 1 to 8 for i 7188 uPAC 7186 PDS 700 series 0 1 3 4 for i 8000 series cCmd Command to be send out Don t need to add CR in back of cCmd iChksum 1 is to enable checksum 0 is to disable checksum Return Value NoError On success Error code refer to Sec 15 constant defined for i 7188 i 8000 uPAC On fail 7186 PDS 700 series MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page230 11 1 2 ReceiveResponseFrom7000_loop Description After calling SendCmdTo7000 user can call ReceiveResponseFrom7000_loop to get the response from 7000 ro I 87K Prototype int ReceiveResponseFrom7000_loop int iPort unsigned char cCmd long Timeout int iChksum Arguments iPort 1 to 8 for i 7188 uPAC 7186 PDS 700 series 0 1 3 4 for i 8000 series cCmd Store response received from 7000 or I 87K If checksum is enabled the function checks and remove the checksum The CR is removed ITimeout Set the timeout unit is times of check COM port If ITimeout 500 the function checks if any data in input buffer five hundred times iChksum 1 is to enable checksum 0 is to disable checksum Return Value NoError On success Error code refer to Sec 1
100. mber of file stored in Flash Memory Prototype int GetFileNo_AB int disk Arguments disk 0 is diskA 1 is diskB Return Value The file number MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page198 10 2 2 GetFileName_AB Description define DISKA 0 define DISKB 1 About the diskA or diskB refer to Sec 10 1 Use file index to get file name Prototype int GetFileName_AB int disk int num char fname Arguments disk 0 is diskA 1 is diskB num The file index The first file is index 0 fname file name Return Value 0 NoError Store the file name to fname 1 Do not save any data to fname MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page199 10 2 3 GetFilelnfoByNo_AB Description define DISKA 0 define DISKB 1 About the diskA or diskB refer to Sec 10 1 Use file index to get file information typedef struct unsigned mark 0x7188 gt is file unsigned char fname 12 unsigned char year unsigned char month unsigned char day unsigned char hour unsigned char minute unsigned char sec unsigned long size char far addr unsigned CRC unsigned CRC32 FILE_DATA Prototype FILE_DATA far GetFilelnfoByNo_AB int disk int no Arguments disk 0 is diskA 1 is diskB no The file index The first file is index 0
101. memory and the peripherals without involvement of the CPU The difference between ReadComn and ReadComn_DMA x is the behavior of data transfer Prototype int ReadComn_DMA_O unsigned char buf int maxsize int ReadComn_DMA_1 unsigned char buf int maxsize int ReadComn_DMA_2 unsigned char buf int maxsize int ReadComn_DMA_3 unsigned char buf int maxsize int ReadComn_DMA_4 unsigned char buf int maxsize Arguments buf The data buffer stores the data that is read from the input buffer of the COM Port maxsize Refer to ReadComn for details Return Values non negative The specified amount of data that has been read from the input buffer MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page49 2 1 41 ReadCom_DMA_x COM Port re sain i 7188XB i 7188XC i 752N i 7 188EX i 7188EA ere i 7188EN UPAC 7186EX series PDS 700 series COM 0 Y COM 1 Y COM 2 Y COM 3 Y Y COM 4 Y Y Y The COM Port can use the ReadCom_DMA x function Description Direct Memory Access DMA permits the transfer of data between the memory and the peripherals without involvement of the CPU The difference between ReadCom and ReadCom_DMA_x is the behavior of the data transfer Prototype int ReadCom_DMA_0 void int ReadCom_DMA_ 1 void int ReadCom_DMA_ 2 void int ReadCom_DMA_ 3 void int ReadCom_DMA_4 vo
102. n is the same for i 8000 series MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page141 8 1 3 LedToggle Description Toggle the status of the red LED If the red LED turns off originally the red LED turns on after LedToggle is called If the red LED turns on originally the red LED turns off after LedToggle is called Prototype void LedToggle void Arguments None Return Value None LED is here The LED location is the same for 1 7188 WPAC 7186 PDS 700 series LED is here The LED location is the same for i 8000 series MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page142 8 2 Respective Functions for all i 7188 i 8000 PAC 7186 PDS 700 Series 8 2 1 Respective Functions Table Functions i 7188 i 752N UPAC 7186 PDS 700 series i 8000 ShowErrLedCom8000 Y SetLedL1 SetLedL2 Y SetLedL3 Y The module can use this function MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page143 8 2 2 ShowErrLedCom8s000 Description This function only for I 8142 l 81421 8144 81441 8112 l 8114 modules This function displays the Error value on the LED Er1 Er4 for the specified slot bit vallue 0 LED ON 1 LED OFF bit O 0x01 for COM port 1 bit 1 0x02 for COM port 2 bit 2 0x04 for COM port 3 for 8144 8114 only bit 3 0x08 for COM port 4 for 8144 8114 only Prototype void ShowErrLedCom8000 int slo
103. n the stack is 16 How to Use CRC16 functions 1 It must call CRC16_MakeTable first to build crc16 table that help CRC16_AddData CRC16_AddDataN to calculate right crc16 value 2 Example1 simple usage of CRC16 functions CRC16_MakeTable Il CRC16_Reset for i i lt datano i CRC16_AddData datali CRC16 CRC16_Read 3 Example2 It needs to calculate another CRC16 value under the process of CRC16 calculation int CheckCrc char data int no unsigned crc unsigned CRC16 Il CRC16_Push CRC16_Reset CRC16_AddDataN data datalen CRC16 CRC16_Read CRC16_Pop return crc CRC16 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page215 char data 256 void funO void unsigned crc CRC16 int datanum int blocknum 0 int CRC_Error 0 CRC16_MakeTable CRC16_Reset while quit amp amp blocknum lt BLOCK_NO datanum GetData data crc GetCrc blocknum if CheckCrc data datanum crc IIcrc OK CRC16_AddDataN data datanum else Il cre error quit 1 CRC_Error 1 if CRC_Error CRC16 CRC16_Read Il 4 The process of CRC16 calculation has to divide many parts crc16_n 0 Il The following way to handle that adding data to calculate CRC16 value in process CRC16_Push store old crc16 value It maybe is the last counting result of CRC16 calculation in another program CRC16_Set crc16_n set initial value of CRC16 in CRC16 cal
104. nd set sw gt uMode 0 After calling T_StopWatchPause it can call T_StopWatchContinue to continue count time typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype void T_StopWatchPause STOPWATCH sw Arguments sw Structure pointer variable Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page164 9 1 2 2 4 T_ StopWatchContinue Description Continue the stopwatch typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype void T_StopWatchContinue STOPWATCH sw Arguments sw Structure pointer variable Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page165 9 1 2 2 5 T_ CountDownTimerStart Description Start the countdowntimer After T_CountDownTimerStart is called it makes cdt gt ulTime timems cdt gt ulStartTime current TimeTicks cdt gt uMode 1 typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype void T_CountDownTimerStart COUNTDOWNTIMER cdt ulong timems Arguments cdt Structure pointer variable timems The countdown time Unit is ms Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page166 9 1 2 2 6 T_CountDownTimerPause
105. nor version number For example Ver 1 15 returns 0x010F MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page272 14 1 5 GetLibDate Description Get library date Prototype void GetLibDate char date Arguments date Store a string about library date The format is like Jan 19 2007 Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page273 14 1 6 ReadiInitPin Description Read the status of INIT pin Prototype int ReadInitPin void Arguments None Return Value 0 InitPinlsOpen Init pin is floating or connected to VCC 1 InitPinlsNotopen Init pin is connected to GND MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page274 14 1 7 hex_to_ascii Description A array that transfers a hexadecimal number to a character The range is 0x0 to OxF Prototype extern char hex_to_ascii 16 Return Value hex_to_ascii Ox0 0 hex_to_ascii 0x1 1 hex_to_ascii Ox2 2 hex_to_ascii Ox3 3 hex_to_ascii Ox4 4 hex_to_ascii Ox5 5 hex_to_ascii Ox6 6 hex_to_ascii Ox7 7 hex_to_ascii Ox8 8 hex_to_ascii Ox9 9 hex_to_ascii OxA A hex_to_ascii OxB B hex_to_ascii OxC C hex_to_ascii OxD D hex_to_ascii OxE E hex_to_ascii OxF F MinoOS7 API Functions Reference Manual ver
106. nt slot int port int mcr Arguments slot 0 1 2 3 port 1 8112 l 8142 8142i 0 1 1 8114 l 8144 0 1 2 3 mcr _MCR_DTRor MCR _ RTS Return Values 0 On success 1 The slot or port is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page80 2 2 28 SetCom8000_MCR_Bit Description This function sets the content of the Modem Control Register MCR for the specified COM Port Prototype int SetCom8000_MCR_Bit int slot int port int mcr_bit Arguments slot 0 1 2 3 port 1 81 12 I 8142 I 8142i 0 1 1 8114 1 8144 0 1 2 3 mcr_bit define MCR_DTR 1 define _MCR_RTS 2 define _MCR_LOOP 0x10 define _MCR_AUTO FLOW_CONTROL 0x20 Return Values On success The slot or port is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page81 2 2 29 ClearCom8000_MCR_Bit Description This function clears the Modem Control Register MCR for the specified COM Port Prototype int ClearCom8000_MCR_Bit int slot int port int mcr_bit Arguments slot 0 1 2 3 port 1 8112 I 8142 I 8142i 0 1 I 8114 1 8144 0 1 2 3 mcr_bit define MCR_DTR 1 define MCR_RTS 2 define MCR_LOOP 0x10 define MCR AUTO FLOW _CONTROL 0x20 Return Value On success The slot or port is invalid MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 P
107. oid Arguments time 100 65535 Unit is 0 1 us fun A pointer that pointer to function Return Value 0 NoError On success 1 time lt 100 2 fun can t be found See also StopUserTimrFun MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page184 9 1 3 4 InstallUserTimerFunction_ms Description Install user s timer function Time unit is ms Default timer is timer 0 and timer 2 timer 2 s output is timer O s input For example If user wants timer generates interrupt every 1 second 1 sec 1000ms That is to say system calls your function once every 1 sec Just use Prototype int InstallUserTimerFunction_ms unsigned time void fun void Arguments time 0 65535 Unit is ms fun A pointer that pointer to function Return Value O NoError On success 2 fun can t be found MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page185 9 1 3 5 StopUserTimerFun Description Stop user s timer function After InstallUserTimerFunction_us or InstallUserTimerFunction_ms is used StopUserTimerFun has to be used to stop user s timer function Prototype void StopUserTimerFun void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page186 9 1 4 Others Functions DelayMs Delay Delay_1 Delay_2 Tim
108. ons Reference Manual version 1 12 Jan 2009 Page68 2 2 18 ReadCom8s000 Description This function reads one byte of data from the input buffer of the specified COM Port Prototype int ReadCom8000 int slot int port Arguments slot 0 1 2 3 port 1 8112 I 8142 l 8142i 0 1 I 8114 1 8144 0 1 2 3 Return Values 0 to 255 On success 1 The slot or port is invalid 6 There is no data in the input buffer of the specified COM Port MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page69 2 2 19 ReadCom8s000nBytes Description This function reads n bytes from the input buffer of the specified COM Port at one time For instance Num is the total number of bytes in the input buffer of the specified COM Port N is number of bytes actually read If maxnum gt Num N Num So Num bytes are read from the input buffer at one time If maxnum lt Num N maxnum So maxnum bytes are read from the input buffer at one time Prototype int ReadCom8000nBytes int slot int port char buf int maxnum Arguments slot 0 1 2 3 port 1 8112 I 8142 I 8142i 0 1 I 8114 l 8144 0 1 2 3 buf The data buffer stores the data that is read from the input buffer of the specified COM Port maxnum The maximum number of bytes to be read from the input buffer if maxnum lt Num The maxnum value has to be less than or equal to the
109. otype ulong T2_CountDownTimerGetTimeLeft COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value 0 Countdown is over Non negative Remnant time Unit is ms MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page180 9 1 3 User Timer Functions A InstallUserTimerFunction_us B InstallUserTimerFunction_ms C StopUserTimerFun InstallUserTimer InstallUserTimer1C A B TimerOpen Used together Used together No TimerClose a Used together Timer Function Every 1ms Every 55 ms User sets the time User sets the time called NOTE InstallUserTimerFunction_us InstallUserTimerFunction_ms Delay Delay_1 Delay_2 i8017H_AD_TimerINT and i8017H_AD_TimerINT_Scan have relations with timerO or timer1 Some rules have to be obeyed below when these functions are used together The first type function nstallUserTimerFunction_us InstallUserTimerFunction_ms The second type function Delay Delay_1 Delay_2 The third type function i8017H_AD_TimerlNT and i8017H_AD_TimerINT_Scan There are three timers timer0 timer1 and timer2 in CPU Rule The third type function uses timer0 Therefore other type functions have to change timer to use timer1 to stop from clashing Rulez2 InstallUserTimerFunction_us InstallUserTimerFunction_ms can t be used at the same time at present even if they use different timer Rule3 The first typ
110. pace 17 dash MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page135 6 gt Jo Ys alls Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page136 7 1 6 Show5DigitLedSeg Description Show any segment of 5 digits of the seven segment LED and also can show the DOT Prototype void pascal Show5DigitLedSeg int pos unsigned char data Arguments pos pos can be 1 2 3 4 5 or 6 1 for the leftmost position 5 for the rightmost position 6 for P1 gt P2 and P3 only for l 8000 series data Range from 0 to 255 When pos is 6 Bit 5 controls P1 Bit 6 controls P2 and Bit 7 controls P3 6 Bit O to 7 control the 8 segments 7 segment and dot as the left figure l If the bit is 1 the segment turns on af P 3 7 a If the bit is 0 the segment turns off For example if user wants to display an L must light segment 1 2 3 So the data must be 0x0E 00001110b For l 8000 series 6 fos 4 ht 7 oS am o E Ee e EE gt af 2s Jaor aff af 4 om o am o om o am o Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page137 7 1 7 Set5DigitLedTestMode Description Set 5 digits of seven segment LED on Normal MODE or Test MODE Prototype void pascal S
111. r IO expansion board About DIO AIO modules of IO expansion board information for i 7188 i 7188EX series CD Napdos 7188XABC Xboard Document or http ftp icodas com pub cd 8000cd napdos 7188xabc xboard document Functions description is in header file like x607 h The header file locations are as follows Expansion board for i 7188XA gt CD Napdos 7188XABC 7188XA Demo BC_TC lib XBoard or http ftp icpdas com pub cd 8000cd napdos 7188xabc 7188xa demo bc_tc lib xboard Expansion board for i 7188XB gt CD Napdos 7188XABC 7188XB Demo BC_TC Lib Xboard or http ftp icpdas com pub cd 8000cd napdos 7188xabc 7188xb demo bc_tc lib xboard Expansion board for i 7188XC gt CD Napdos 7188XABC 7188XC Demo BC_TC LIB Xboard or http ftp icpdas com pub cd 8000cd napdos 7188xabc 7188xc demo bc_tc lib xboard Expansion board for i 7188EX gt CD Napdos 7188e Demo BC_TC Lib Xboard or http ftp icpdas com pub cd 8000cd napdos 7188e demo bc _tc lib xboard MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page237 Expansion board for uPAC 7186EX series gt CD Napdos 7186e Demo Lib Xboard or http ftp icodas com pub cd 8000cd napdos 7 186e demo lib xboard 12 3 1O For i 8000 12 3 1 i 8K series 12 3 1 1 DO Functions Description Set the output value of i 8000 Digital output module DO_8 for the D O modules that have 1 8 output points DO_16 for the D O modules that have 1 16 output points DO_32 for the D O modules th
112. r off And NVRAM has no limit on the number of the re write times FLASH and EEPROM both have the limit on re write times If the leakage current is not happened the battary can be used 10 years 4 The following functions work if the module is equipped with RTC The standard version of i 7188XC i 7521 I 7522 7523 I 7 188EN parts of i 8000 series PDS 700 series without RTC MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page116 5 1 Common Functions for all i 7188 i 8000 uPAC 7186 Series Modules 5 1 1 ReadNVRAM Description This function reads data from the NVRAM Prototype int ReadNVRAM int addr Arguments addr O to 30 a total of 31 bytes Return Values 0 255 On success 9 AddrError The addr is invalid MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page117 5 1 2 WriteNVRAM Description Write data to NVRAM Prototype int WriteNVRAM int addr int data Arguments addr 0 to 30 data One byte data 0 255 If data gt 255 only the low byte is written to NVRAM Return Values 0 NoError On success 9 AddrError On fail MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page118 5 1 3 SetTimeDay Description Set the system time and date to the RTC of the module When calling SetTimeDate it just needs to set the right year month day and then the function auto s
113. ries has 8 slots for add on modules The last 4 slots share the same interrupt signal ClrAllSlotInt can mask all interrupt singal of all slots Prototype void ClrAllSlotint void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page292 14 3 10 KeyStatus Description Read current system key status If the bit value is 0 the key status is up If the bit value is 1 the key status is down define SKEY_SET_DOWN 0x08 define SKEY_DOWN_DOWN 0x04 define SKEY_UP_DOWN 0x02 define SKEY_MODE_DOWN 0x01 Prototype extern unsigned char far const KeyStatus Note KeyStatus GetSystemKey GetSystemKey Difference 1 Read current system key values 1 Read FIFO buffer value 2 Four key data one time 2 One key data one time 3 Real time data 3 May be real time data MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page293 14 3 11 IsSystemKey Description Check if any input of system key is available in the system key input buffer FIFO buffer size is 16 If InstallNewTimer is called it must use _IsSystemKey instead of IsSystemKey Prototype int IsSystemKey void int _IsSystemKey void Arguments None Return Value 0 For no any input of system key Others There is input data of system key in the buffer MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page294 14 3 1
114. ruct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype ulong T_CountDownTimerGetTimeLeft COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value 0 Countdown is over Non negative Remnant time Unit is ms MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page170 9 1 2 3 Third Kind Functions 9 1 2 3 1 T2_UpdateCurrentTimeTicks Description Store current TimeTicls value into an internal parameter called NormTimeTicks The calculation method for T2_StopWatchxxxx and T2_CountDownTimerxxxx is based on NormTimeTicks T2_UpdateCurrentTimeTicks must be called to get new TimeTicls value every loop so that other functions T2_StopWatchxxxxx T2_CountDownTimerxxxx can update their status Prototype void T2_UpdateCurrentTimeTicks void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page171 9 1 2 3 2 T2_StopWatchStart Description Start to use a stopwatch record the current NormTimeTicks value sw gt ulStart NormTimeTicks Refer to Sec 9 1 2 3 1 about NormTimeTicks and set sw gt uMode 1 The sw gt ulStart is the start value of stopwatch typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype void T2_StopWatchStart STOPWATCH sw Arguments sw S
115. s Total size is 512K bytes S5256 8512 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page121 6 1 6 1 1 Common Functions for all i 8000 Series 256 _Init Description Do an initializing operation for functions relative to S256 S512 It must call this function before other S256 S512 functions are used Prototype int S256_Init void Arguments None Return Values 512 Ram size is 512K S512 256 Ram size is 256K S256 0 No S256 or S512 module is found MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page122 6 1 2 256 _Read Description Read data from SRAM Prototype int S256 _Read unsigned block unsigned offset Arguments block 0 2047 for S256 module 0 4095 for S512 module offset 0 127 Return Values 0 255 Data sotred in SRAM 10 BlockError block is out of range 100 OffsetError offset is out of range MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page123 6 1 3 256 Write Description Write data to SRAM Prototype int S256_Write unsigned block unsigned offset unsigned char data Arguments block 0 2047 for S256 module 0 4095 for S512 module offset 0 127 data 0 255 the data to send out Return Values 0 NoError On success 10 BlockError block is out of range
116. s is only 512K bytes MiniOS7 uses the last 64K bytes the other parts of the memory are used to store user s program or data User s program also can use functions to write data to Flash Memory 2 When user want to write data to Flash Memory it only can be written from 1 to 0 can not be written from 0 to 1 So in general before the FLASH is written data FLASH must be erased the erase process makes all data to OxFF that is all data bit is 1 Then any data can be written to it 4 1 Common Functions for all i 7188 i 8000 uPAC 7186 PDS 700 Series 4 1 1 FlashReadid Description Read Flash memory device code high byte and manufacture code low byte Prototype int FlashReadld void Arguments None Return Values 0xBOC2 MXIC 29f002NT 0xB001 AMD 29F002T 256K type OxA4C2 MXIC 29f040 0xA401 AMD 29f040 512K type 0xB5C2 MXIC 29LV004T MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page109 4 1 2 FlashErase Description Erases one sector 64K bytes of the Flash Memory all data in that sector are changed to OxFF Prototype int FlashErase unsigned seg Arguments seg 1 For 256K type seg can be 0xC000 0xDO00 OxE000 2 For 512K type seg can be 0x8000 0x9000 0xA000 0xB000 OxC000 0xD000 OxE000 3 The segment 0xF000 is used for MiniOS7 If seg OxF000 FlashErase does nothing Return Value 0 NoError On success 5 TimeO
117. sion 1 12 Jan 2009 Page275 14 1 8 ascii_to_hex Description Transform a character into a hexadecimal number Prototype int ascii_to_hex char ascii Arguments ascii A character that is ready to be transformed Only 0 1 2 3 4 5 6 7 8 9 A B C D E Fa b c d e and f can be transformed Return Value Ox0 OxF On success MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page276 14 1 9 IsResetByPowerOn Description Check if the module is reset by power on Prototype int lsResetByPowerOn void Arguments None Return Value 1 Reset by power on Not reset by power on MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page277 14 1 10 IsResetByWatchDogTimer Description Check if the module is reset by watchdog timer Prototype int lsResetByWatchDogTimer void Arguments None Return Value 1 Reset by watchdog timer Not reset by watchdog timer MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page278 14 2 Respective Functions for all i 7188 i 8000 uPAC 7186 PDS 700 Series 14 2 1 Respective Functions Table Functions i 7188XA i 7188XB i 7188EX i 7188EA i 7188EN i 7188 i 7188XC i 752N PDS 700 series UPAC 7186EX pPAC 7186EX FD UPAC 7186EX FM uPAC 7 186EX SM i 8000
118. ssion has failed MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page78 2 2 26 ToCom8s000nBytes Description This function sends n bytes of data to the specified COM Port The data are initially stored in the software output buffer When the hardware output buffer is empty the data are sent using the ISR Interrupt Service Routine Prototype int ToComs8000nBytes int slot int port char buf int num Arguments slot 0 1 2 3 port 1 8112 I 8142 l 8142i 0 1 l 8114 1 8144 0 1 2 3 buf The data buffer num The number of bytes of data to be sent where the value num is less than or equal to the size of the buf Return Values 0 On success the data has been stored in the software output buffer 1 The slot or port is invalid 5 Data transmission has failed MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page79 2 2 27 SetCom8s000_MCR Description This function sets the bit O DTR and bit 1 RTS of the Modem Control Register MCR for the specified COM Port To set the RTS as active also active DTR call SetCom8000_MCR slot port MCR_DTR _MCR_RTS To set the RTS as inactive only active DTR call SetCom8000_MCR slot port MCR_DTR Call SetCom8000_MCR slot port 0 to set both RTS and DTR as inactive The definition of each bit is as follows define MCR_DTR 1 define MCR_RTS 2 Prototype int SetCom8000_MCRii
119. stored in the input buffer of COMO Prototype unsigned Com0GetDataSize void Arguments None Return Values Non negative The size of the data stored in the input buffer MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page90 2 3 4 Com0SetinputBuf Description This function sets new address and size of input buffer where the DMA stores the received data User can read Com0GetDataSize to know how much data had been received Prototype void Com0SetInputBuf char far ptr unsigned cnt Arguments ptr The buffer that stores the data received by the DMA cnt Buffer size Return Values None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page91 2 4 COM4 without Using Interrupt for I 8431_1 8831 Remark 1 The two functions are suitable only for 40M Hz CPU in this section 2 When COMO uses DMA method Com0GetDataSize Com0SetInputBuf to send receive data COM4 has no interrupt to use some functions that send data to COM4 or receive data from COM4 like IsCom 4 ReadCom 4 ToCom 4 ToComStr 4 printCom 4 and etc Using EnableMonitorCom4 and DisableMonitorCom4 can solve this problem MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page92 2 4 1 EnableMonitorCom4 Description This function can let these function that send data to COM4 or receive data from COM4 like IsCom 4 ReadCom 4
120. t int data Arguments slot 0 1 2 3 data The valid range is from 0 to 15 Return Value None LED Er1 Er4 for 8142 8 1421 1 8 144 1 8 1441 8112 l 8114 MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page144 8 2 3 SetLedLx Description Set the display mode of LED L1 L2 L3 on l 8000 series Prototype void SetLedL1 int mode void SetLedL2 int mode void SetLedL3 int mode Arguments mode 0 LED_OFF Dark LED 1 LED_ON Light LED 2 LED_TOGGLE Toggle LED status Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page145 9 Timer and WatchDogTimer Functions Variables Remark 1 MiniOS7 uses the TIMER 2 one of CPU internal timer as system Timer It is 16 bits timer and generate interrupt every 1 ms So the accuracy of system is 1 ms P S 1 8000 system s timer generates interrupt every 5 ms 2 User can install user s timer function It is suitable to check some status every fixed time period The system timer ISR Interrupt Service Routine will calls INT 9 interrupt in passing and every 55 ms calls INT Ox1C P S The timer functions of 8000 s library use timer 1 it generates interrupt every 1 ms 9 1 Common Functions Varlables for all i 7188 i 8000 uPAC 7186 PDS 700 Series 9 1 1 WatchDogTimer Functions 9 1 1 1 EnableWDT Description The WatchDog Timer WDT is always enabl
121. tch Refer to Sec 9 1 2 3 1 typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype void T2_StopWatchContinue STOPWATCH sw Arguments sw Structure pointer variable Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page175 9 1 2 3 6 T2_CountDownTimerStart Description Start the countdowntimer After T2_CountDownTimerStart is called it makes cdt gt ulTime timems cdt gt ulStartTime current NormTimeTicks Refer to Sec 9 1 2 3 1 about NormTimeTicks cdt gt uMode 1 typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype void T2_CountDownTimerStart COUNTDOWNTIMER cdt ulong timems Arguments cat Structure pointer variable timems The countdown time Unit is ms Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page176 9 1 2 3 7 T2_CountDownTimerPause Description Pause the countdowntimer It makes cdt gt ulPauseTime current NormTimeTicks Refer to Sec 9 1 2 3 1 about NormTimetTicks typedef struct ulong ulTime ulStartTime ulPauseTime uint uMode 0 pause 1 run start COUNTDOWNTIMER Prototype void T2_CountDownTimerPause COUNTDOWNTIMER cdt Arguments cd Structure pointer variable Return Value None MinoO
122. the low byte are sent out Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page263 13 1 7 Puts Description Send a string to standard I O port Note If Installcom 1 is called this function is not used Prototype void Puts char str Arguments str Point to the string which is to send Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page264 13 1 8 Print Description This function is used to replace printf and the only difference between Print and printf is Print does not transfer n to n r That is to say the code Ox0A is only sent out about n not OxOA 0x0D The printed message is sent out to standard I O port Default format setting 115200 N 8 1 Note If Installcom 1 is called this function is not used Prototype int Print const char fmt Arguments Please refer to C s standard function printf Return Value the number of bytes output On success EOF refer to C s constant define On error MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page265 13 1 9 ResetScanBuffer Description Set Scanf to use default input buffer maxlen 80 Prototype void ResetScanBuffer void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page266 13 1 10 SetScanBuffer Description Set user s
123. tructure pointer variable Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page172 9 1 2 3 3 T2_StopWatchGetTime Description Read current stopwatch value NormTimetTicks Refer to Sec 9 1 2 3 1 about NormTimeTicks value affects current stopwatch value If NormTimetTicks value still not changing T2_StopWatchGetTime reads the same value continuously typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype ulong T2_StopWatchGetTime STOPWATCH sw Arguments sw Structure pointer variable Return Value Non negative Current stopwatch value MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page173 9 1 2 3 4 T2_StopWatchPause Description Pause the stopwatch Record current TimeTicks value to sw gt ulPauseTime sw gt ulPauseTime NormTimeTicks Refer to Sec 9 1 2 3 1 about NormTimeTicks and set sw gt uMode 0 After calling T2_StopWatchPause it can call T2_StopWatchContinue to continue count time typedef struct ulong ulStart ulPauseTime uint uMode 0 pause 1 run start STOPWATCH Prototype void T2_StopWatchPause STOPWATCH sw Arguments sw Structure pointer variable Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page174 9 1 2 3 5 T2_StopWatchContinue Description Continue the stopwa
124. ual version 1 12 Jan 2009 Page219 10 3 2 3 CRC16 Pop Description Pop CRC16 value off stack There are 16 layers in the stack Prototype int CRC16_Pop void Arguments None Return Value 0 On success 1 Stack is underflow MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page220 10 3 2 4 CRC16 Set Description Set current CRC16 value define CRC16_Reset CRC16_Set 0 Prototype void CRC16_Set unsigned val Arguments val New CRC 16 value Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page221 10 3 2 5 CRC16_Read Description Read current CRC16 value Prototype unsigned CRC16_Read void Arguments None Return Value CRC16 value calculated by system MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page222 10 3 2 6 CRC16_AddData Description Add one byte data to calculate new CRC16 value that can be read from CRC16_Read Prototype void CRC16_AddData unsigned char data Arguments data Add the data to calculate new CRC16 value Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page223 10 3 2 7 CRC16_AddDataN Description Add n bytes data to calculate new CRC16 value that can be read from CRC16_Read Prototype void CRC16_AddDataN unsigned char far data unsigned length Arguments
125. ual version 1 12 Jan 2009 Page227 10 3 2 11 Modbus_CRC16_Read Description Read current CRC16 value Prototype unsigned Modbus_CRC16_Read void Arguments None Return Value CRC16 value calculated by system MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page228 10 3 2 12 Modbus_GetCRC16 Description Add n bytes data to calculate new CRC 16 value that can be read from Modbus _CRC16_Read Prototype void Modbus_GetCRC16 unsigned char puchMsg int DataLen Arguments puchMsg Points to an address that this function want to add data from DataLen Number of data the function attempts to add Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page229 11 Connect to i 7000 Modules Functions Remark 1 When user wants to use i 7188 i 8000 uPAC 7186 PDS 700 series to control i 7000 series module they can use the following three functions 2 After calling SendCmdTo7000 it must call ReceiveResponseFrom7000_ms or ReceiveResponseFrom7000_loop to receive the response of i 7000 module P S If the command SendCmdTo7000 has no response it need not call ReceiveResponseFrom7000_ms or ReceiveResponseFrom7 000_loop 3 The InstallCom must be called before using those functions in this chapter 11 1 Common Functions for all i 7188 i 8000 uPAC 7186 PDS 700 Series 11 1 1 SendCmdTo7000 Description Send com
126. upports new timer ISR and does not call INT 0x1C every 55 ms After InstallNewTimer is called it must use _IsSystemKey instead of IsSystemKey _GetSystemKey instead of GetSystemKey and _ClearSystemKey instead of ClearSystemKey Prototype void InstallNewTimer void Arguments None Return Value None MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page297 14 3 15 AddCom2Fun Description After calling AddCom2Fun the functions for COM2 are linked into the exe file The default setting is IsCom 2 ReadCom 2 do not work for I 8x1x After calling AddCom2Fun IsCom 2 ReadCom 2 work for I 8x1x Note IsCom_2 ReadCom_2 always work for I 8x1x Prototype void AddCom2Fun void Arguments None Return Value None MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page298 15 Constant Defined for i 7188 i 8000 uPAC 7186 PDS 700 Series Name Value NoError 0 InitPinlsOpen 0 InitPinlsNotopen 1 QueuelsEmpty 0 QueuelsNotEmpty 1 PortError 1 DataError 2 ParityError 3 StopError 4 TimeOut 5 QueueEmpty 6 QueueOverflow 7 PosError 8 AddrError 9 BlockError 10 WriteError 11 SegmentError 12 BaudRateError 13 CheckSumError 14 ChannelError 15 TriggerLevelError 17 DateError 18 TimeError 19 OutOfMemory 20 TimelsUp 1 MinoOS7 API Functions Reference Manual version 1 12 Jan 2
127. ut On failure MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page110 4 1 3 FlashWrite Description Writes one byte of data to the Flash memory When data is written to the the Flash Memory each bit can only be changed from 1 to 0 So if the data in that position is Oxff any data can be written But if the data in that position is 0x01 only 0x00 can be written When an attempt is made to change the bit from 0 to 1 TimeoutError occurs Data can be written again only afters FlashErase is called Prototype int FlashWrite unsigned int seg unsigned int offset char data Arguments seg 1 For 256K type seg can be 0xC000 0xDO00 OxE000 2 For 512K type seg can be 0x8000 0x9000 0xA000 0xB000 0xC000 0xD000 OxE000 3 The segment OxF000 is used for MiniOs7 If seg 0xF000 FlashWrite does nothing offset 0 to 65535 Oxffff data 0 to 255 8 bit data Return Value 0 NoError On success 12 SegmentError seg is invalid Otherwise On failure MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page111 4 1 4 FlashReadB Description Reads data from the FLASH memory where the size is that of the unsigned char A far pointer can also be used to access the data on the Flash memory directly The code is char far ByteData databyte ByteData char far MK_FP segment offset databyte ByteData Prototype unsigned char FlashReadB uns
128. value For example Original Correspondence long st long st st GetTimeTicks_ISR _asm pushf _asm cli st TimeTicks _asm popf According to above table interrupt flag does not be changed after GetTimeTicks_ISR is called Prototype long GetTimeTicks_ISR void Arguments None Return Value TimeTicks value On success MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page193 9 2 Respective Functions for all i 7188 i 8000 WPAC 7186 PDS 700 Series 9 2 1 Respective Functions Table Functions vine i 7188XA i 7188XB i 7188XC i 752N i 7188EX i 7 188EA i 7188EN l uPAC 7186 series PDS 700 series i 8000 SetDelayTimer Y SetUserTimer Y Y The module can use this function MiniOS7 API Functions Reference Manual version 1 12 Jan 2009 Page194 9 2 2 SetDelayTimer Description The default timer of delay functions Dealy Delay_1 Delay_2 use system s timer 0 User can call SetDelayTimer 1 to set them to use timer 1 Prototype int SetDelayTimer int num Arguments num num 0 use timer 0 num 1 use timer 1 Return Value 0 Use timer 0 Use timer 1 MinoOS7 API Functions Reference Manual version 1 12 Jan 2009 Page195 9 2 3 SetUserTimer Description The default timer of user timer functions InstallUserTimerFunction_us InstallUserTimerFunction_ms use system s timer 0

Download Pdf Manuals

image

Related Search

Related Contents

Samsung 570DX Uporabniški priročnik  Benq MX501  K2 Dyno S Replay Controller User Manual  Camaraderie n.261 xe  SIERRA VIDEO  

Copyright © All rights reserved.
Failed to retrieve file