Backup before error handling refactoring

This commit is contained in:
jkwoo
2026-07-13 17:10:02 +09:00
commit 04fc19b485
1132 changed files with 347840 additions and 0 deletions

View File

@@ -0,0 +1,309 @@
@********************************************************************************************************
@ uC/LIB
@ CUSTOM LIBRARY MODULES
@
@ (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL
@
@ All rights reserved. Protected by international copyright laws.
@
@ uC/LIB is provided in source form to registered licensees ONLY. It is
@ illegal to distribute this source code to any third party unless you receive
@ written permission by an authorized Micrium representative. Knowledge of
@ the source code may NOT be used to develop a similar product.
@
@ Please help us continue to provide the Embedded community with the finest
@ software available. Your honesty is greatly appreciated.
@
@ You can contact us at www.micrium.com.
@********************************************************************************************************
@********************************************************************************************************
@
@ STANDARD MEMORY OPERATIONS
@
@ ARM-Cortex-M3
@ GNU Compiler
@
@ Filename : lib_mem_a.s
@ Version : V1.36.01.00
@ Programmer(s) : JDH
@ DC
@********************************************************************************************************
@ Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
@
@ (a) ALL standard library functions are implemented in the custom library modules :
@
@ (1) \<Custom Library Directory>\lib*.*
@
@ (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
@
@ where
@ <Custom Library Directory> directory path for custom library software
@ <cpu> directory name for specific processor (CPU)
@ <compiler> directory name for specific compiler
@
@ (b) Product-specific library functions are implemented in individual products.
@
@ (2) Assumes ARM CPU mode configured for Little Endian.
@********************************************************************************************************
@********************************************************************************************************
@ PUBLIC FUNCTIONS
@********************************************************************************************************
.global Mem_Copy
@********************************************************************************************************
@ CODE GENERATION DIRECTIVES
@********************************************************************************************************
.text
.align 2
.thumb
.syntax unified
@$PAGE
@********************************************************************************************************
@ Mem_Copy()
@
@ Description : Copy data octets from one buffer to another buffer.
@
@ Argument(s) : pdest Pointer to destination memory buffer.
@
@ psrc Pointer to source memory buffer.
@
@ size Number of data buffer octets to copy.
@
@ Return(s) : none.
@
@ Caller(s) : Application.
@
@ Note(s) : (1) Null copies allowed (i.e. 0-octet size).
@
@ (2) Memory buffers NOT checked for overlapping.
@
@ (3) Modulo arithmetic is used to determine whether a memory buffer starts on a 'CPU_ALIGN'
@ address boundary.
@
@ (4) ARM Cortex-M3 processors use a subset of the ARM Thumb-2 instruction set which does
@ NOT support 16-bit conditional branch instructions but ONLY supports 8-bit conditional
@ branch instructions.
@
@ Therefore, branches exceeding 8-bit, signed, relative offsets :
@
@ (a) CANNOT be implemented with conditional branches@ but ...
@ (b) MUST be implemented with non-conditional branches.
@********************************************************************************************************
@ void Mem_Copy (void *pdest, @ ==> R0
@ void *psrc, @ ==> R1
@ CPU_SIZE_T size) @ ==> R2
.thumb_func
Mem_Copy:
CMP R0, #0
BNE Mem_Copy_1
BX LR @ return if pdest == NULL
Mem_Copy_1:
CMP R1, #0
BNE Mem_Copy_2
BX LR @ return if psrc == NULL
Mem_Copy_2:
CMP R2, #0
BNE Mem_Copy_3
BX LR @ return if size == 0
Mem_Copy_3:
STMFD SP!, {R3-R12} @ save registers on stack
@$PAGE
Chk_Align_32: @ check if both dest & src 32-bit aligned
AND R3, R0, #0x03
AND R4, R1, #0x03
CMP R3, R4
BNE Chk_Align_16 @ not 32-bit aligned, check for 16-bit alignment
RSB R3, R3, #0x04 @ compute 1-2-3 pre-copy bytes (to align to the next 32-bit boundary)
AND R3, R3, #0x03
Pre_Copy_1:
CMP R3, #1 @ copy 1-2-3 bytes (to align to the next 32-bit boundary)
BCC Copy_32_1 @ start real 32-bit copy
CMP R2, #1 @ check if any more data to copy
BCS Pre_Copy_1_Cont
B Mem_Copy_END @ no more data to copy (see Note #4b)
Pre_Copy_1_Cont:
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_1
Chk_Align_16: @ check if both dest & src 16-bit aligned
AND R3, R0, #0x01
AND R4, R1, #0x01
CMP R3, R4
BEQ Pre_Copy_2
B Copy_08_1 @ not 16-bit aligned, start 8-bit copy (see Note #4b)
Pre_Copy_2:
CMP R3, #1 @ copy 1 byte (to align to the next 16-bit boundary)
BCC Copy_16_1 @ start real 16-bit copy
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_2
Copy_32_1:
CMP R2, #360 @ Copy 9 chunks of 10 32-bit words (360 octets per loop)
BCC Copy_32_2
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #360
B Copy_32_1
Copy_32_2:
CMP R2, #(04*10*01) @ Copy chunks of 10 32-bit words (40 octets per loop)
BCC Copy_32_3
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #(04*10*01)
B Copy_32_2
Copy_32_3:
CMP R2, #(04*01*01) @ Copy remaining 32-bit words
BCC Copy_16_1
LDR R3, [R1], #4
STR R3, [R0], #4
SUB R2, R2, #(04*01*01)
B Copy_32_3
@$PAGE
Copy_16_1:
CMP R2, #(02*01*16) @ Copy chunks of 16 16-bit words (32 bytes per loop)
BCC Copy_16_2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*16)
B Copy_16_1
Copy_16_2:
CMP R2, #(02*01*01) @ Copy remaining 16-bit words
BCC Copy_08_1
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*01)
B Copy_16_2
@$PAGE
Copy_08_1:
CMP R2, #(01*01*16) @ Copy chunks of 16 8-bit words (16 bytes per loop)
BCC Copy_08_2
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*16)
B Copy_08_1
Copy_08_2:
CMP R2, #(01*01*01) @ Copy remaining 8-bit words
BCC Mem_Copy_END
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*01)
B Copy_08_2
Mem_Copy_END:
LDMFD SP!, {R3-R12} @ restore registers from stack
BX LR @ return
.end

View File

@@ -0,0 +1,306 @@
;********************************************************************************************************
; uC/LIB
; CUSTOM LIBRARY MODULES
;
; (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL
;
; All rights reserved. Protected by international copyright laws.
;
; uC/LIB is provided in source form to registered licensees ONLY. It is
; illegal to distribute this source code to any third party unless you receive
; written permission by an authorized Micrium representative. Knowledge of
; the source code may NOT be used to develop a similar product.
;
; Please help us continue to provide the Embedded community with the finest
; software available. Your honesty is greatly appreciated.
;
; You can contact us at www.micrium.com.
;********************************************************************************************************
;********************************************************************************************************
;
; STANDARD MEMORY OPERATIONS
;
; ARM-Cortex-M3
; IAR Compiler
;
; Filename : lib_mem_a.asm
; Version : V1.36.01.00
; Programmer(s) : JDH
; BAN
;********************************************************************************************************
; Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
;
; (a) ALL standard library functions are implemented in the custom library modules :
;
; (1) \<Custom Library Directory>\lib*.*
;
; (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
;
; where
; <Custom Library Directory> directory path for custom library software
; <cpu> directory name for specific processor (CPU)
; <compiler> directory name for specific compiler
;
; (b) Product-specific library functions are implemented in individual products.
;
; (2) Assumes ARM CPU mode configured for Little Endian.
;********************************************************************************************************
;********************************************************************************************************
; PUBLIC FUNCTIONS
;********************************************************************************************************
PUBLIC Mem_Copy
;********************************************************************************************************
; CODE GENERATION DIRECTIVES
;********************************************************************************************************
RSEG CODE:CODE:NOROOT(2)
;$PAGE
;********************************************************************************************************
; Mem_Copy()
;
; Description : Copy data octets from one buffer to another buffer.
;
; Argument(s) : pdest Pointer to destination memory buffer.
;
; psrc Pointer to source memory buffer.
;
; size Number of data buffer octets to copy.
;
; Return(s) : none.
;
; Caller(s) : Application.
;
; Note(s) : (1) Null copies allowed (i.e. 0-octet size).
;
; (2) Memory buffers NOT checked for overlapping.
;
; (3) Modulo arithmetic is used to determine whether a memory buffer starts on a 'CPU_ALIGN'
; address boundary.
;
; (4) ARM Cortex-M3 processors use a subset of the ARM Thumb-2 instruction set which does
; NOT support 16-bit conditional branch instructions but ONLY supports 8-bit conditional
; branch instructions.
;
; Therefore, branches exceeding 8-bit, signed, relative offsets :
;
; (a) CANNOT be implemented with conditional branches; but ...
; (b) MUST be implemented with non-conditional branches.
;********************************************************************************************************
; void Mem_Copy (void *pdest, ; ==> R0
; void *psrc, ; ==> R1
; CPU_SIZE_T size) ; ==> R2
Mem_Copy:
CMP R0, #0
BNE Mem_Copy_1
BX LR ; return if pdest == NULL
Mem_Copy_1:
CMP R1, #0
BNE Mem_Copy_2
BX LR ; return if psrc == NULL
Mem_Copy_2:
CMP R2, #0
BNE Mem_Copy_3
BX LR ; return if size == 0
Mem_Copy_3:
STMFD SP!, {R3-R12} ; save registers on stack
;$PAGE
Chk_Align_32: ; check if both dest & src 32-bit aligned
AND R3, R0, #0x03
AND R4, R1, #0x03
CMP R3, R4
BNE Chk_Align_16 ; not 32-bit aligned, check for 16-bit alignment
RSB R3, R3, #0x04 ; compute 1-2-3 pre-copy bytes (to align to the next 32-bit boundary)
AND R3, R3, #0x03
Pre_Copy_1:
CMP R3, #1 ; copy 1-2-3 bytes (to align to the next 32-bit boundary)
BCC Copy_32_1 ; start real 32-bit copy
CMP R2, #1 ; check if any more data to copy
BCS Pre_Copy_1_Cont
B Mem_Copy_END ; no more data to copy (see Note #4b)
Pre_Copy_1_Cont:
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_1
Chk_Align_16: ; check if both dest & src 16-bit aligned
AND R3, R0, #0x01
AND R4, R1, #0x01
CMP R3, R4
BEQ Pre_Copy_2
B Copy_08_1 ; not 16-bit aligned, start 8-bit copy (see Note #4b)
Pre_Copy_2:
CMP R3, #1 ; copy 1 byte (to align to the next 16-bit boundary)
BCC Copy_16_1 ; start real 16-bit copy
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_2
Copy_32_1:
CMP R2, #(04*10*09) ; Copy 9 chunks of 10 32-bit words (360 octets per loop)
BCC Copy_32_2
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #(04*10*09)
B Copy_32_1
Copy_32_2:
CMP R2, #(04*10*01) ; Copy chunks of 10 32-bit words (40 octets per loop)
BCC Copy_32_3
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #(04*10*01)
B Copy_32_2
Copy_32_3:
CMP R2, #(04*01*01) ; Copy remaining 32-bit words
BCC Copy_16_1
LDR R3, [R1], #4
STR R3, [R0], #4
SUB R2, R2, #(04*01*01)
B Copy_32_3
;$PAGE
Copy_16_1:
CMP R2, #(02*01*16) ; Copy chunks of 16 16-bit words (32 bytes per loop)
BCC Copy_16_2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*16)
B Copy_16_1
Copy_16_2:
CMP R2, #(02*01*01) ; Copy remaining 16-bit words
BCC Copy_08_1
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*01)
B Copy_16_2
;$PAGE
Copy_08_1:
CMP R2, #(01*01*16) ; Copy chunks of 16 8-bit words (16 bytes per loop)
BCC Copy_08_2
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*16)
B Copy_08_1
Copy_08_2:
CMP R2, #(01*01*01) ; Copy remaining 8-bit words
BCC Mem_Copy_END
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*01)
B Copy_08_2
Mem_Copy_END:
LDMFD SP!, {R3-R12} ; restore registers from stack
BX LR ; return
END

View File

@@ -0,0 +1,312 @@
;********************************************************************************************************
; uC/LIB
; CUSTOM LIBRARY MODULES
;
; (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL
;
; All rights reserved. Protected by international copyright laws.
;
; uC/LIB is provided in source form to registered licensees ONLY. It is
; illegal to distribute this source code to any third party unless you receive
; written permission by an authorized Micrium representative. Knowledge of
; the source code may NOT be used to develop a similar product.
;
; Please help us continue to provide the Embedded community with the finest
; software available. Your honesty is greatly appreciated.
;
; You can contact us at www.micrium.com.
;********************************************************************************************************
;********************************************************************************************************
;
; STANDARD MEMORY OPERATIONS
;
; ARM-Cortex-M3
; RealView Development Suite
; RealView Microcontroller Development Kit (MDK)
; ARM Developer Suite (ADS)
; Keil uVision
;
; Filename : lib_mem_a.asm
; Version : V1.36.01.00
; Programmer(s) : JDH
; BAN
;********************************************************************************************************
; Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
;
; (a) ALL standard library functions are implemented in the custom library modules :
;
; (1) \<Custom Library Directory>\lib*.*
;
; (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
;
; where
; <Custom Library Directory> directory path for custom library software
; <cpu> directory name for specific processor (CPU)
; <compiler> directory name for specific compiler
;
; (b) Product-specific library functions are implemented in individual products.
;
; (2) Assumes ARM CPU mode configured for Little Endian.
;********************************************************************************************************
;********************************************************************************************************
; PUBLIC FUNCTIONS
;********************************************************************************************************
EXPORT Mem_Copy
;********************************************************************************************************
; CODE GENERATION DIRECTIVES
;********************************************************************************************************
AREA |.text|, CODE, READONLY, ALIGN=2
THUMB
REQUIRE8
PRESERVE8
;$PAGE
;********************************************************************************************************
; Mem_Copy()
;
; Description : Copy data octets from one buffer to another buffer.
;
; Argument(s) : pdest Pointer to destination memory buffer.
;
; psrc Pointer to source memory buffer.
;
; size Number of data buffer octets to copy.
;
; Return(s) : none.
;
; Caller(s) : Application.
;
; Note(s) : (1) Null copies allowed (i.e. 0-octet size).
;
; (2) Memory buffers NOT checked for overlapping.
;
; (3) Modulo arithmetic is used to determine whether a memory buffer starts on a 'CPU_ALIGN'
; address boundary.
;
; (4) ARM Cortex-M3 processors use a subset of the ARM Thumb-2 instruction set which does
; NOT support 16-bit conditional branch instructions but ONLY supports 8-bit conditional
; branch instructions.
;
; Therefore, branches exceeding 8-bit, signed, relative offsets :
;
; (a) CANNOT be implemented with conditional branches; but ...
; (b) MUST be implemented with non-conditional branches.
;********************************************************************************************************
; void Mem_Copy (void *pdest, ; ==> R0
; void *psrc, ; ==> R1
; CPU_SIZE_T size) ; ==> R2
Mem_Copy
CMP R0, #0
BNE Mem_Copy_1
BX LR ; return if pdest == NULL
Mem_Copy_1
CMP R1, #0
BNE Mem_Copy_2
BX LR ; return if psrc == NULL
Mem_Copy_2
CMP R2, #0
BNE Mem_Copy_3
BX LR ; return if size == 0
Mem_Copy_3
STMFD SP!, {R3-R12} ; save registers on stack
;$PAGE
Chk_Align_32 ; check if both dest & src 32-bit aligned
AND R3, R0, #0x03
AND R4, R1, #0x03
CMP R3, R4
BNE Chk_Align_16 ; not 32-bit aligned, check for 16-bit alignment
RSB R3, R3, #0x04 ; compute 1-2-3 pre-copy bytes (to align to the next 32-bit boundary)
AND R3, R3, #0x03
Pre_Copy_1
CMP R3, #1 ; copy 1-2-3 bytes (to align to the next 32-bit boundary)
BCC Copy_32_1 ; start real 32-bit copy
CMP R2, #1 ; check if any more data to copy
BCS Pre_Copy_1_Cont
B Mem_Copy_END ; no more data to copy (see Note #4b)
Pre_Copy_1_Cont
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_1
Chk_Align_16 ; check if both dest & src 16-bit aligned
AND R3, R0, #0x01
AND R4, R1, #0x01
CMP R3, R4
BEQ Pre_Copy_2
B Copy_08_1 ; not 16-bit aligned, start 8-bit copy (see Note #4b)
Pre_Copy_2
CMP R3, #1 ; copy 1 byte (to align to the next 16-bit boundary)
BCC Copy_16_1 ; start real 16-bit copy
LDRB R4, [R1], #1
STRB R4, [R0], #1
SUB R3, R3, #1
SUB R2, R2, #1
B Pre_Copy_2
Copy_32_1
CMP R2, #(04*10*09) ; Copy 9 chunks of 10 32-bit words (360 octets per loop)
BCC Copy_32_2
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #(04*10*09)
B Copy_32_1
Copy_32_2
CMP R2, #(04*10*01) ; Copy chunks of 10 32-bit words (40 octets per loop)
BCC Copy_32_3
LDMIA R1!, {R3-R12}
STMIA R0!, {R3-R12}
SUB R2, R2, #(04*10*01)
B Copy_32_2
Copy_32_3
CMP R2, #(04*01*01) ; Copy remaining 32-bit words
BCC Copy_16_1
LDR R3, [R1], #4
STR R3, [R0], #4
SUB R2, R2, #(04*01*01)
B Copy_32_3
;$PAGE
Copy_16_1
CMP R2, #(02*01*16) ; Copy chunks of 16 16-bit words (32 bytes per loop)
BCC Copy_16_2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*16)
B Copy_16_1
Copy_16_2
CMP R2, #(02*01*01) ; Copy remaining 16-bit words
BCC Copy_08_1
LDRH R3, [R1], #2
STRH R3, [R0], #2
SUB R2, R2, #(02*01*01)
B Copy_16_2
;$PAGE
Copy_08_1
CMP R2, #(01*01*16) ; Copy chunks of 16 8-bit words (16 bytes per loop)
BCC Copy_08_2
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*16)
B Copy_08_1
Copy_08_2
CMP R2, #(01*01*01) ; Copy remaining 8-bit words
BCC Mem_Copy_END
LDRB R3, [R1], #1
STRB R3, [R0], #1
SUB R2, R2, #(01*01*01)
B Copy_08_2
Mem_Copy_END
LDMFD SP!, {R3-R12} ; restore registers from stack
BX LR ; return
END

View File

@@ -0,0 +1,661 @@
/*
*********************************************************************************************************
* uC/LIB
* CUSTOM LIBRARY MODULES
*
* (c) Copyright 2004-2012; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/LIB is provided in source form to registered licensees ONLY. It is
* illegal to distribute this source code to any third party unless you receive
* written permission by an authorized Micrium representative. Knowledge of
* the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*
* You can contact us at www.micrium.com.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* ASCII CHARACTER OPERATIONS
*
* Filename : lib_ascii.c
* Version : V1.37.01
* Programmer(s) : BAN
* ITJ
*********************************************************************************************************
* Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
*
* (a) ALL standard library functions are implemented in the custom library modules :
*
* (1) \<Custom Library Directory>\lib_*.*
*
* (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
*
* where
* <Custom Library Directory> directory path for custom library software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (b) Product-specific library functions are implemented in individual products.
*
*
* (2) (a) ECMA-6 '7-Bit coded Character Set' (6th edition), which corresponds to the
* 3rd edition of ISO 646, specifies several versions of a 7-bit character set :
*
* (1) THE GENERAL VERSION, which allows characters at 0x23 and 0x24 to be given a
* set alternate form and allows the characters 0x40, 0x5B, 0x5D, 0x60, 0x7B &
* 0x7D to be assigned a "unique graphic character" or to be declared as unused.
* All other characters are explicitly specified.
*
* (2) THE INTERNATIONAL REFERENCE VERSION, which explicitly specifies all characters
* in the 7-bit character set.
*
* (3) NATIONAL & APPLICATION-ORIENTED VERSIONS, which may be derived from the
* standard in specified ways.
*
* (b) The character set represented in this file reproduces the Internation Reference
* Version. This is identical to the 7-bit character set which occupies Unicode
* characters 0x0000 through 0x007F. The character names are taken from v5.0 of the
* Unicode specification, with certain abbreviations so that the resulting #define
* names will not violate ANSI C naming restriction :
*
* (1) For the Latin capital & lowercase letters, the name components 'LETTER_CAPITAL'
* & 'LETTER_SMALL' are replaced by 'UPPER' & 'LOWER', respectively.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#define MICRIUM_SOURCE
#define LIB_ASCII_MODULE
#include <lib_ascii.h>
/*$PAGE*/
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL TABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IsAlpha()
*
* Description : Determine whether a character is an alphabetic character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an alphabetic character.
*
* DEF_NO, if character is NOT an alphabetic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.2.(2) states that "isalpha() returns true only for the
* characters for which isupper() or islower() is true".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsAlpha (CPU_CHAR c)
{
CPU_BOOLEAN alpha;
alpha = ASCII_IS_ALPHA(c);
return (alpha);
}
/*
*********************************************************************************************************
* ASCII_IsAlphaNum()
*
* Description : Determine whether a character is an alphanumeric character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an alphanumeric character.
*
* DEF_NO, if character is NOT an alphanumeric character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.1.(2) states that "isalnum() ... tests for any character
* for which isalpha() or isdigit() is true".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsAlphaNum (CPU_CHAR c)
{
CPU_BOOLEAN alpha_num;
alpha_num = ASCII_IS_ALPHA_NUM(c);
return (alpha_num);
}
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IsLower()
*
* Description : Determine whether a character is a lowercase alphabetic character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a lowercase alphabetic character.
*
* DEF_NO, if character is NOT a lowercase alphabetic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.7.(2) states that "islower() returns true only for
* the lowercase letters".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsLower (CPU_CHAR c)
{
CPU_BOOLEAN lower;
lower = ASCII_IS_LOWER(c);
return (lower);
}
/*
*********************************************************************************************************
* ASCII_IsUpper()
*
* Description : Determine whether a character is an uppercase alphabetic character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an uppercase alphabetic character.
*
* DEF_NO, if character is NOT an uppercase alphabetic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.11.(2) states that "isupper() returns true only for
* the uppercase letters".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsUpper (CPU_CHAR c)
{
CPU_BOOLEAN upper;
upper = ASCII_IS_UPPER(c);
return (upper);
}
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IsDig()
*
* Description : Determine whether a character is a decimal-digit character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a decimal-digit character.
*
* DEF_NO, if character is NOT a decimal-digit character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.5.(2) states that "isdigit() ... tests for any
* decimal-digit character".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsDig (CPU_CHAR c)
{
CPU_BOOLEAN dig;
dig = ASCII_IS_DIG(c);
return (dig);
}
/*
*********************************************************************************************************
* ASCII_IsDigOct()
*
* Description : Determine whether a character is an octal-digit character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an octal-digit character.
*
* DEF_NO, if character is NOT an octal-digit character.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsDigOct (CPU_CHAR c)
{
CPU_BOOLEAN dig_oct;
dig_oct = ASCII_IS_DIG_OCT(c);
return (dig_oct);
}
/*
*********************************************************************************************************
* ASCII_IsDigHex()
*
* Description : Determine whether a character is a hexadecimal-digit character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a hexadecimal-digit character.
*
* DEF_NO, if character is NOT a hexadecimal-digit character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.12.(2) states that "isxdigit() ... tests for any
* hexadecimal-digit character".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsDigHex (CPU_CHAR c)
{
CPU_BOOLEAN dig_hex;
dig_hex = ASCII_IS_DIG_HEX(c);
return (dig_hex);
}
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IsBlank()
*
* Description : Determine whether a character is a standard blank character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a standard blank character.
*
* DEF_NO, if character is NOT a standard blank character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) states that "isblank() returns true only for
* the standard blank characters".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) defines "the standard blank characters" as
* the "space (' '), and horizontal tab ('\t')".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsBlank (CPU_CHAR c)
{
CPU_BOOLEAN blank;
blank = ASCII_IS_BLANK(c);
return (blank);
}
/*
*********************************************************************************************************
* ASCII_IsSpace()
*
* Description : Determine whether a character is a white-space character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a white-space character.
*
* DEF_NO, if character is NOT a white-space character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) states that "isspace() returns true only
* for the standard white-space characters".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) defines "the standard white-space characters"
* as the "space (' '), form feed ('\f'), new-line ('\n'), carriage return ('\r'),
* horizontal tab ('\t'), and vertical tab ('\v')".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsSpace (CPU_CHAR c)
{
CPU_BOOLEAN space;
space = ASCII_IS_SPACE(c);
return (space);
}
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IsPrint()
*
* Description : Determine whether a character is a printing character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a printing character.
*
* DEF_NO, if character is NOT a printing character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.8.(2) states that "isprint() ... tests for any
* printing character including space (' ')".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
* ASCII character set, the printing characters are those whose values lie from
* 0x20 (space) through 0x7E (tilde)".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsPrint (CPU_CHAR c)
{
CPU_BOOLEAN print;
print = ASCII_IS_PRINT(c);
return (print);
}
/*
*********************************************************************************************************
* ASCII_IsGraph()
*
* Description : Determine whether a character is any printing character except a space character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a graphic character.
*
* DEF_NO, if character is NOT a graphic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.6.(2) states that "isgraph() ... tests for any
* printing character except space (' ')".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
* ASCII character set, the printing characters are those whose values lie from
* 0x20 (space) through 0x7E (tilde)".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsGraph (CPU_CHAR c)
{
CPU_BOOLEAN graph;
graph = ASCII_IS_GRAPH(c);
return (graph);
}
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IsPunct()
*
* Description : Determine whether a character is a punctuation character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a punctuation character.
*
* DEF_NO, if character is NOT a punctuation character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.9.(2) states that "ispunct() returns true for every
* printing character for which neither isspace() nor isalnum() is true".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsPunct (CPU_CHAR c)
{
CPU_BOOLEAN punct;
punct = ASCII_IS_PUNCT(c);
return (punct);
}
/*
*********************************************************************************************************
* ASCII_IsCtrl()
*
* Description : Determine whether a character is a control character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a control character.
*
* DEF_NO, if character is NOT a control character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.4.(2) states that "iscntrl() ... tests for any
* control character".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
* ASCII character set, ... the control characters are those whose values lie from
* 0 (NUL) through 0x1F (US), and the character 0x7F (DEL)".
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsCtrl (CPU_CHAR c)
{
CPU_BOOLEAN ctrl;
ctrl = ASCII_IS_CTRL(c);
return (ctrl);
}
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_ToLower()
*
* Description : Convert uppercase alphabetic character to its corresponding lowercase alphabetic character.
*
* Argument(s) : c Character to convert.
*
* Return(s) : Lowercase equivalent of 'c', if character 'c' is an uppercase character (see Note #1b1).
*
* Character 'c', otherwise (see Note #1b2).
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.1.(2) states that "tolower() ... converts an
* uppercase letter to a corresponding lowercase letter".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.2.1.(3) states that :
*
* (1) (A) "if the argument is a character for which isupper() is true and there are
* one or more corresponding characters ... for which islower() is true," ...
* (B) "tolower() ... returns one of the corresponding characters;" ...
*
* (2) "otherwise, the argument is returned unchanged."
*********************************************************************************************************
*/
CPU_CHAR ASCII_ToLower (CPU_CHAR c)
{
CPU_CHAR lower;
lower = ASCII_TO_LOWER(c);
return (lower);
}
/*
*********************************************************************************************************
* ASCII_ToUpper()
*
* Description : Convert lowercase alphabetic character to its corresponding uppercase alphabetic character.
*
* Argument(s) : c Character to convert.
*
* Return(s) : Uppercase equivalent of 'c', if character 'c' is a lowercase character (see Note #1b1).
*
* Character 'c', otherwise (see Note #1b2).
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.2.(2) states that "toupper() ... converts a
* lowercase letter to a corresponding uppercase letter".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.2.2.(3) states that :
*
* (1) (A) "if the argument is a character for which islower() is true and there are
* one or more corresponding characters ... for which isupper() is true," ...
* (B) "toupper() ... returns one of the corresponding characters;" ...
*
* (2) "otherwise, the argument is returned unchanged."
*********************************************************************************************************
*/
CPU_CHAR ASCII_ToUpper (CPU_CHAR c)
{
CPU_CHAR upper;
upper = ASCII_TO_UPPER(c);
return (upper);
}
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_Cmp()
*
* Description : Determine if two characters are identical (case-insensitive).
*
* Argument(s) : c1 First character.
*
* c2 Second character.
*
* Return(s) : DEF_YES, if the characters are identical.
*
* DEF_NO, if the characters are NOT identical.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_Cmp (CPU_CHAR c1,
CPU_CHAR c2)
{
CPU_CHAR c1_upper;
CPU_CHAR c2_upper;
CPU_BOOLEAN cmp;
c1_upper = ASCII_ToUpper(c1);
c2_upper = ASCII_ToUpper(c2);
cmp = (c1_upper == c2_upper) ? (DEF_YES) : (DEF_NO);
return (cmp);
}

View File

@@ -0,0 +1,853 @@
/*
*********************************************************************************************************
* uC/LIB
* CUSTOM LIBRARY MODULES
*
* (c) Copyright 2004-2012; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/LIB is provided in source form to registered licensees ONLY. It is
* illegal to distribute this source code to any third party unless you receive
* written permission by an authorized Micrium representative. Knowledge of
* the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*
* You can contact us at www.micrium.com.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* ASCII CHARACTER OPERATIONS
*
* Filename : lib_ascii.h
* Version : V1.37.01
* Programmer(s) : BAN
*********************************************************************************************************
* Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
*
* (a) ALL standard library functions are implemented in the custom library modules :
*
* (1) \<Custom Library Directory>\lib_*.*
*
* (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
*
* where
* <Custom Library Directory> directory path for custom library software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (b) Product-specific library functions are implemented in individual products.
*
*
* (2) (a) ECMA-6 '7-Bit coded Character Set' (6th edition), which corresponds to the
* 3rd edition of ISO 646, specifies several versions of a 7-bit character set :
*
* (1) THE GENERAL VERSION, which allows characters at 0x23 and 0x24 to be given a
* set alternate form and allows the characters 0x40, 0x5B, 0x5D, 0x60, 0x7B &
* 0x7D to be assigned a "unique graphic character" or to be declared as unused.
* All other characters are explicitly specified.
*
* (2) THE INTERNATIONAL REFERENCE VERSION, which explicitly specifies all characters
* in the 7-bit character set.
*
* (3) NATIONAL & APPLICATION-ORIENTED VERSIONS, which may be derived from the
* standard in specified ways.
*
* (b) The character set represented in this file reproduces the Internation Reference
* Version. This is identical to the 7-bit character set which occupies Unicode
* characters 0x0000 through 0x007F. The character names are taken from v5.0 of the
* Unicode specification, with certain abbreviations so that the resulting #define
* names will not violate ANSI C naming restriction :
*
* (1) For the Latin capital & lowercase letters, the name components 'LETTER_CAPITAL'
* & 'LETTER_SMALL' are replaced by 'UPPER' & 'LOWER', respectively.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE
*
* Note(s) : (1) This ASCII library header file is protected from multiple pre-processor inclusion through
* use of the ASCII library module present pre-processor macro definition.
*********************************************************************************************************
*/
#ifndef LIB_ASCII_MODULE_PRESENT /* See Note #1. */
#define LIB_ASCII_MODULE_PRESENT
/*$PAGE*/
/*
*********************************************************************************************************
* INCLUDE FILES
*
* Note(s) : (1) The custom library software files are located in the following directories :
*
* (a) \<Custom Library Directory>\lib_*.*
*
* where
* <Custom Library Directory> directory path for custom library software
*
* (2) CPU-configuration software files are located in the following directories :
*
* (a) \<CPU-Compiler Directory>\cpu_*.*
* (b) \<CPU-Compiler Directory>\<cpu>\<compiler>\cpu*.*
*
* where
* <CPU-Compiler Directory> directory path for common CPU-compiler software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (3) Compiler MUST be configured to include as additional include path directories :
*
* (a) '\<Custom Library Directory>\' directory See Note #1a
*
* (b) (1) '\<CPU-Compiler Directory>\' directory See Note #2a
* (2) '\<CPU-Compiler Directory>\<cpu>\<compiler>\' directory See Note #2b
*
* (4) NO compiler-supplied standard library functions SHOULD be used.
*********************************************************************************************************
*/
#include <cpu.h>
#include <lib_def.h>
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef LIB_ASCII_MODULE
#define LIB_ASCII_EXT
#else
#define LIB_ASCII_EXT extern
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ASCII CHARACTER DEFINES
*********************************************************************************************************
*/
/* -------------------- C0 CONTROLS ------------------- */
#define ASCII_CHAR_NULL 0x00 /* '\0' */
#define ASCII_CHAR_START_OF_HEADING 0x01
#define ASCII_CHAR_START_OF_TEXT 0x02
#define ASCII_CHAR_END_OF_TEXT 0x03
#define ASCII_CHAR_END_OF_TRANSMISSION 0x04
#define ASCII_CHAR_ENQUIRY 0x05
#define ASCII_CHAR_ACKNOWLEDGE 0x06
#define ASCII_CHAR_BELL 0x07 /* '\a' */
#define ASCII_CHAR_BACKSPACE 0x08 /* '\b' */
#define ASCII_CHAR_CHARACTER_TABULATION 0x09 /* '\t' */
#define ASCII_CHAR_LINE_FEED 0x0A /* '\n' */
#define ASCII_CHAR_LINE_TABULATION 0x0B /* '\v' */
#define ASCII_CHAR_FORM_FEED 0x0C /* '\f' */
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D /* '\r' */
#define ASCII_CHAR_SHIFT_OUT 0x0E
#define ASCII_CHAR_SHIFT_IN 0x0F
#define ASCII_CHAR_DATA_LINK_ESCAPE 0x10
#define ASCII_CHAR_DEVICE_CONTROL_ONE 0x11
#define ASCII_CHAR_DEVICE_CONTROL_TWO 0x12
#define ASCII_CHAR_DEVICE_CONTROL_THREE 0x13
#define ASCII_CHAR_DEVICE_CONTROL_FOUR 0x14
#define ASCII_CHAR_NEGATIVE_ACKNOWLEDGE 0x15
#define ASCII_CHAR_SYNCHRONOUS_IDLE 0x16
#define ASCII_CHAR_END_OF_TRANSMISSION_BLOCK 0x17
#define ASCII_CHAR_CANCEL 0x18
#define ASCII_CHAR_END_OF_MEDIUM 0x19
#define ASCII_CHAR_SUBSITUTE 0x1A
#define ASCII_CHAR_ESCAPE 0x1B
#define ASCII_CHAR_INFO_SEPARATOR_FOUR 0x1C
#define ASCII_CHAR_INFO_SEPARATOR_THREE 0x1D
#define ASCII_CHAR_INFO_SEPARATOR_TWO 0x1E
#define ASCII_CHAR_INFO_SEPARATOR_ONE 0x1F
#define ASCII_CHAR_NUL ASCII_CHAR_NULL
#define ASCII_CHAR_SOH ASCII_CHAR_START_OF_HEADING
#define ASCII_CHAR_START_HEADING ASCII_CHAR_START_OF_HEADING
#define ASCII_CHAR_STX ASCII_CHAR_START_OF_TEXT
#define ASCII_CHAR_START_TEXT ASCII_CHAR_START_OF_TEXT
#define ASCII_CHAR_ETX ASCII_CHAR_END_OF_TEXT
#define ASCII_CHAR_END_TEXT ASCII_CHAR_END_OF_TEXT
#define ASCII_CHAR_EOT ASCII_CHAR_END_OF_TRANSMISSION
#define ASCII_CHAR_END_TRANSMISSION ASCII_CHAR_END_OF_TRANSMISSION
#define ASCII_CHAR_ENQ ASCII_CHAR_ENQUIRY
#define ASCII_CHAR_ACK ASCII_CHAR_ACKNOWLEDGE
#define ASCII_CHAR_BEL ASCII_CHAR_BELL
#define ASCII_CHAR_BS ASCII_CHAR_BACKSPACE
#define ASCII_CHAR_HT ASCII_CHAR_CHARACTER_TABULATION
#define ASCII_CHAR_TAB ASCII_CHAR_CHARACTER_TABULATION
#define ASCII_CHAR_LF ASCII_CHAR_LINE_FEED
#define ASCII_CHAR_VT ASCII_CHAR_LINE_TABULATION
#define ASCII_CHAR_FF ASCII_CHAR_FORM_FEED
#define ASCII_CHAR_CR ASCII_CHAR_CARRIAGE_RETURN
#define ASCII_CHAR_SO ASCII_CHAR_SHIFT_OUT
#define ASCII_CHAR_SI ASCII_CHAR_SHIFT_IN
#define ASCII_CHAR_DLE ASCII_CHAR_DATA_LINK_ESCAPE
#define ASCII_CHAR_DC1 ASCII_CHAR_DEVICE_CONTROL_ONE
#define ASCII_CHAR_DC2 ASCII_CHAR_DEVICE_CONTROL_TWO
#define ASCII_CHAR_DC3 ASCII_CHAR_DEVICE_CONTROL_THREE
#define ASCII_CHAR_DC4 ASCII_CHAR_DEVICE_CONTROL_FOUR
#define ASCII_CHAR_DEV_CTRL_ONE ASCII_CHAR_DEVICE_CONTROL_ONE
#define ASCII_CHAR_DEV_CTRL_TWO ASCII_CHAR_DEVICE_CONTROL_TWO
#define ASCII_CHAR_DEV_CTRL_THREE ASCII_CHAR_DEVICE_CONTROL_THREE
#define ASCII_CHAR_DEV_CTRL_FOUR ASCII_CHAR_DEVICE_CONTROL_FOUR
#define ASCII_CHAR_NAK ASCII_CHAR_NEGATIVE_ACKNOWLEDGE
#define ASCII_CHAR_NEG_ACK ASCII_CHAR_NEGATIVE_ACKNOWLEDGE
#define ASCII_CHAR_SYN ASCII_CHAR_SYNCHRONOUS_IDLE
#define ASCII_CHAR_SYNC_IDLE ASCII_CHAR_SYNCHRONOUS_IDLE
#define ASCII_CHAR_ETB ASCII_CHAR_END_OF_TRANSMISSION_BLOCK
#define ASCII_CHAR_END_TRANSMISSION_BLK ASCII_CHAR_END_OF_TRANSMISSION_BLOCK
#define ASCII_CHAR_CAN ASCII_CHAR_CANCEL
#define ASCII_CHAR_EM ASCII_CHAR_END_OF_MEDIUM
#define ASCII_CHAR_END_MEDIUM ASCII_CHAR_END_OF_MEDIUM
#define ASCII_CHAR_SUB ASCII_CHAR_SUBSITUTE
#define ASCII_CHAR_ESC ASCII_CHAR_ESCAPE
#define ASCII_CHAR_IS1 ASCII_CHAR_INFO_SEPARATOR_ONE
#define ASCII_CHAR_IS2 ASCII_CHAR_INFO_SEPARATOR_TWO
#define ASCII_CHAR_IS3 ASCII_CHAR_INFO_SEPARATOR_THREE
#define ASCII_CHAR_IS4 ASCII_CHAR_INFO_SEPARATOR_FOUR
/*$PAGE*/
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
#define ASCII_CHAR_SPACE 0x20 /* ' ' */
#define ASCII_CHAR_EXCLAMATION_MARK 0x21 /* '!' */
#define ASCII_CHAR_QUOTATION_MARK 0x22 /* '\"' */
#define ASCII_CHAR_NUMBER_SIGN 0x23 /* '#' */
#define ASCII_CHAR_DOLLAR_SIGN 0x24 /* '$' */
#define ASCII_CHAR_PERCENTAGE_SIGN 0x25 /* '%' */
#define ASCII_CHAR_AMPERSAND 0x26 /* '&' */
#define ASCII_CHAR_APOSTROPHE 0x27 /* '\'' */
#define ASCII_CHAR_LEFT_PARENTHESIS 0x28 /* '(' */
#define ASCII_CHAR_RIGHT_PARENTHESIS 0x29 /* ')' */
#define ASCII_CHAR_ASTERISK 0x2A /* '*' */
#define ASCII_CHAR_PLUS_SIGN 0x2B /* '+' */
#define ASCII_CHAR_COMMA 0x2C /* ',' */
#define ASCII_CHAR_HYPHEN_MINUS 0x2D /* '-' */
#define ASCII_CHAR_FULL_STOP 0x2E /* '.' */
#define ASCII_CHAR_SOLIDUS 0x2F /* '/' */
#define ASCII_CHAR_PAREN_LEFT ASCII_CHAR_LEFT_PARENTHESIS
#define ASCII_CHAR_PAREN_RIGHT ASCII_CHAR_RIGHT_PARENTHESIS
/* ------------------- ASCII DIGITS ------------------- */
#define ASCII_CHAR_DIGIT_ZERO 0x30 /* '0' */
#define ASCII_CHAR_DIGIT_ONE 0x31 /* '1' */
#define ASCII_CHAR_DIGIT_TWO 0x32 /* '2' */
#define ASCII_CHAR_DIGIT_THREE 0x33 /* '3' */
#define ASCII_CHAR_DIGIT_FOUR 0x34 /* '4' */
#define ASCII_CHAR_DIGIT_FIVE 0x35 /* '5' */
#define ASCII_CHAR_DIGIT_SIX 0x36 /* '6' */
#define ASCII_CHAR_DIGIT_SEVEN 0x37 /* '7' */
#define ASCII_CHAR_DIGIT_EIGHT 0x38 /* '8' */
#define ASCII_CHAR_DIGIT_NINE 0x39 /* '9' */
#define ASCII_CHAR_DIG_ZERO ASCII_CHAR_DIGIT_ZERO
#define ASCII_CHAR_DIG_ONE ASCII_CHAR_DIGIT_ONE
#define ASCII_CHAR_DIG_TWO ASCII_CHAR_DIGIT_TWO
#define ASCII_CHAR_DIG_THREE ASCII_CHAR_DIGIT_THREE
#define ASCII_CHAR_DIG_FOUR ASCII_CHAR_DIGIT_FOUR
#define ASCII_CHAR_DIG_FIVE ASCII_CHAR_DIGIT_FIVE
#define ASCII_CHAR_DIG_SIX ASCII_CHAR_DIGIT_SIX
#define ASCII_CHAR_DIG_SEVEN ASCII_CHAR_DIGIT_SEVEN
#define ASCII_CHAR_DIG_EIGHT ASCII_CHAR_DIGIT_EIGHT
#define ASCII_CHAR_DIG_NINE ASCII_CHAR_DIGIT_NINE
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
#define ASCII_CHAR_COLON 0x3A /* ':' */
#define ASCII_CHAR_SEMICOLON 0x3B /* ';' */
#define ASCII_CHAR_LESS_THAN_SIGN 0x3C /* '<' */
#define ASCII_CHAR_EQUALS_SIGN 0x3D /* '=' */
#define ASCII_CHAR_GREATER_THAN_SIGN 0x3E /* '>' */
#define ASCII_CHAR_QUESTION_MARK 0x3F /* '\?' */
#define ASCII_CHAR_COMMERCIAL_AT 0x40 /* '@' */
#define ASCII_CHAR_AT_SIGN ASCII_CHAR_COMMERCIAL_AT
/*$PAGE*/
/* ------------- UPPERCASE LATIN ALPHABET ------------- */
#define ASCII_CHAR_LATIN_UPPER_A 0x41 /* 'A' */
#define ASCII_CHAR_LATIN_UPPER_B 0x42 /* 'B' */
#define ASCII_CHAR_LATIN_UPPER_C 0x43 /* 'C' */
#define ASCII_CHAR_LATIN_UPPER_D 0x44 /* 'D' */
#define ASCII_CHAR_LATIN_UPPER_E 0x45 /* 'E' */
#define ASCII_CHAR_LATIN_UPPER_F 0x46 /* 'F' */
#define ASCII_CHAR_LATIN_UPPER_G 0x47 /* 'G' */
#define ASCII_CHAR_LATIN_UPPER_H 0x48 /* 'H' */
#define ASCII_CHAR_LATIN_UPPER_I 0x49 /* 'I' */
#define ASCII_CHAR_LATIN_UPPER_J 0x4A /* 'J' */
#define ASCII_CHAR_LATIN_UPPER_K 0x4B /* 'K' */
#define ASCII_CHAR_LATIN_UPPER_L 0x4C /* 'L' */
#define ASCII_CHAR_LATIN_UPPER_M 0x4D /* 'M' */
#define ASCII_CHAR_LATIN_UPPER_N 0x4E /* 'N' */
#define ASCII_CHAR_LATIN_UPPER_O 0x4F /* 'O' */
#define ASCII_CHAR_LATIN_UPPER_P 0x50 /* 'P' */
#define ASCII_CHAR_LATIN_UPPER_Q 0x51 /* 'Q' */
#define ASCII_CHAR_LATIN_UPPER_R 0x52 /* 'R' */
#define ASCII_CHAR_LATIN_UPPER_S 0x53 /* 'S' */
#define ASCII_CHAR_LATIN_UPPER_T 0x54 /* 'T' */
#define ASCII_CHAR_LATIN_UPPER_U 0x55 /* 'U' */
#define ASCII_CHAR_LATIN_UPPER_V 0x56 /* 'V' */
#define ASCII_CHAR_LATIN_UPPER_W 0x57 /* 'W' */
#define ASCII_CHAR_LATIN_UPPER_X 0x58 /* 'X' */
#define ASCII_CHAR_LATIN_UPPER_Y 0x59 /* 'Y' */
#define ASCII_CHAR_LATIN_UPPER_Z 0x5A /* 'Z' */
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
#define ASCII_CHAR_LEFT_SQUARE_BRACKET 0x5B /* '[' */
#define ASCII_CHAR_REVERSE_SOLIDUS 0x5C /* '\\' */
#define ASCII_CHAR_RIGHT_SQUARE_BRACKET 0x5D /* ']' */
#define ASCII_CHAR_CIRCUMFLEX_ACCENT 0x5E /* '^' */
#define ASCII_CHAR_LOW_LINE 0x5F /* '_' */
#define ASCII_CHAR_GRAVE_ACCENT 0x60 /* '`' */
#define ASCII_CHAR_BRACKET_SQUARE_LEFT ASCII_CHAR_LEFT_SQUARE_BRACKET
#define ASCII_CHAR_BRACKET_SQUARE_RIGHT ASCII_CHAR_RIGHT_SQUARE_BRACKET
/* ------------- LOWERCASE LATIN ALPHABET ------------- */
#define ASCII_CHAR_LATIN_LOWER_A 0x61 /* 'a' */
#define ASCII_CHAR_LATIN_LOWER_B 0x62 /* 'b' */
#define ASCII_CHAR_LATIN_LOWER_C 0x63 /* 'c' */
#define ASCII_CHAR_LATIN_LOWER_D 0x64 /* 'd' */
#define ASCII_CHAR_LATIN_LOWER_E 0x65 /* 'e' */
#define ASCII_CHAR_LATIN_LOWER_F 0x66 /* 'f' */
#define ASCII_CHAR_LATIN_LOWER_G 0x67 /* 'g' */
#define ASCII_CHAR_LATIN_LOWER_H 0x68 /* 'h' */
#define ASCII_CHAR_LATIN_LOWER_I 0x69 /* 'i' */
#define ASCII_CHAR_LATIN_LOWER_J 0x6A /* 'j' */
#define ASCII_CHAR_LATIN_LOWER_K 0x6B /* 'k' */
#define ASCII_CHAR_LATIN_LOWER_L 0x6C /* 'l' */
#define ASCII_CHAR_LATIN_LOWER_M 0x6D /* 'm' */
#define ASCII_CHAR_LATIN_LOWER_N 0x6E /* 'n' */
#define ASCII_CHAR_LATIN_LOWER_O 0x6F /* 'o' */
#define ASCII_CHAR_LATIN_LOWER_P 0x70 /* 'p' */
#define ASCII_CHAR_LATIN_LOWER_Q 0x71 /* 'q' */
#define ASCII_CHAR_LATIN_LOWER_R 0x72 /* 'r' */
#define ASCII_CHAR_LATIN_LOWER_S 0x73 /* 's' */
#define ASCII_CHAR_LATIN_LOWER_T 0x74 /* 't' */
#define ASCII_CHAR_LATIN_LOWER_U 0x75 /* 'u' */
#define ASCII_CHAR_LATIN_LOWER_V 0x76 /* 'v' */
#define ASCII_CHAR_LATIN_LOWER_W 0x77 /* 'w' */
#define ASCII_CHAR_LATIN_LOWER_X 0x78 /* 'x' */
#define ASCII_CHAR_LATIN_LOWER_Y 0x79 /* 'y' */
#define ASCII_CHAR_LATIN_LOWER_Z 0x7A /* 'z' */
/* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */
#define ASCII_CHAR_LEFT_CURLY_BRACKET 0x7B /* '{' */
#define ASCII_CHAR_VERTICAL_LINE 0x7C /* '|' */
#define ASCII_CHAR_RIGHT_CURLY_BRACKET 0x7D /* '}' */
#define ASCII_CHAR_TILDE 0x7E /* '~' */
#define ASCII_CHAR_BRACKET_CURLY_LEFT ASCII_CHAR_LEFT_CURLY_BRACKET
#define ASCII_CHAR_BRACKET_CURLY_RIGHT ASCII_CHAR_RIGHT_CURLY_BRACKET
/* ---------------- CONTROL CHARACTERS ---------------- */
#define ASCII_CHAR_DELETE 0x7F
#define ASCII_CHAR_DEL ASCII_CHAR_DELETE
/*$PAGE*/
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
/*$PAGE*/
/*
*********************************************************************************************************
* MACRO'S
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ASCII CHARACTER CLASSIFICATION MACRO's
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.(1) states that "character classification functions ...
* return nonzero (true) if and only if the value of the argument 'c' conforms to ... the
* description of the function."
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ASCII_IS_DIG()
*
* Description : Determine whether a character is a decimal-digit character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a decimal-digit character.
*
* DEF_NO, if character is NOT a decimal-digit character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.5.(2) states that "isdigit() ... tests for any
* decimal-digit character".
*********************************************************************************************************
*/
#define ASCII_IS_DIG(c) ((((c) >= ASCII_CHAR_DIG_ZERO) && ((c) <= ASCII_CHAR_DIG_NINE)) ? (DEF_YES) : (DEF_NO))
/*
*********************************************************************************************************
* ASCII_IS_DIG_OCT()
*
* Description : Determine whether a character is an octal-digit character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an octal-digit character.
*
* DEF_NO, if character is NOT an octal-digit character.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
#define ASCII_IS_DIG_OCT(c) ((((c) >= ASCII_CHAR_DIG_ZERO) && ((c) <= ASCII_CHAR_DIG_SEVEN)) ? (DEF_YES) : (DEF_NO))
/*
*********************************************************************************************************
* ASCII_IS_DIG_HEX()
*
* Description : Determine whether a character is a hexadecimal-digit character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a hexadecimal-digit character.
*
* DEF_NO, if character is NOT a hexadecimal-digit character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.12.(2) states that "isxdigit() ... tests for any
* hexadecimal-digit character".
*********************************************************************************************************
*/
#define ASCII_IS_DIG_HEX(c) (((((c) >= ASCII_CHAR_DIG_ZERO ) && ((c) <= ASCII_CHAR_DIG_NINE )) || \
(((c) >= ASCII_CHAR_LATIN_UPPER_A) && ((c) <= ASCII_CHAR_LATIN_UPPER_F)) || \
(((c) >= ASCII_CHAR_LATIN_LOWER_A) && ((c) <= ASCII_CHAR_LATIN_LOWER_F))) ? (DEF_YES) : (DEF_NO))
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IS_LOWER()
*
* Description : Determine whether a character is a lowercase alphabetic character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a lowercase alphabetic character.
*
* DEF_NO, if character is NOT a lowercase alphabetic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.7.(2) states that "islower() returns true only for
* the lowercase letters".
*********************************************************************************************************
*/
#define ASCII_IS_LOWER(c) ((((c) >= ASCII_CHAR_LATIN_LOWER_A) && ((c) <= ASCII_CHAR_LATIN_LOWER_Z)) ? (DEF_YES) : (DEF_NO))
/*
*********************************************************************************************************
* ASCII_IS_UPPER()
*
* Description : Determine whether a character is an uppercase alphabetic character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an uppercase alphabetic character.
*
* DEF_NO, if character is NOT an uppercase alphabetic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.11.(2) states that "isupper() returns true only for
* the uppercase letters".
*********************************************************************************************************
*/
#define ASCII_IS_UPPER(c) ((((c) >= ASCII_CHAR_LATIN_UPPER_A) && ((c) <= ASCII_CHAR_LATIN_UPPER_Z)) ? (DEF_YES) : (DEF_NO))
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IS_ALPHA()
*
* Description : Determine whether a character is an alphabetic character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an alphabetic character.
*
* DEF_NO, if character is NOT an alphabetic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.2.(2) states that "isalpha() returns true only for the
* characters for which isupper() or islower() is true".
*********************************************************************************************************
*/
#define ASCII_IS_ALPHA(c) ((((ASCII_IS_UPPER(c)) == DEF_YES) || \
((ASCII_IS_LOWER(c)) == DEF_YES)) ? (DEF_YES) : (DEF_NO))
/*
*********************************************************************************************************
* ASCII_IS_ALPHA_NUM()
*
* Description : Determine whether a character is an alphanumeric character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is an alphanumeric character.
*
* DEF_NO, if character is NOT an alphanumeric character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.1.(2) states that "isalnum() ... tests for any character
* for which isalpha() or isdigit() is true".
*********************************************************************************************************
*/
#define ASCII_IS_ALPHA_NUM(c) ((((ASCII_IS_ALPHA(c)) == DEF_YES) || \
((ASCII_IS_DIG (c)) == DEF_YES)) ? (DEF_YES) : (DEF_NO))
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IS_BLANK()
*
* Description : Determine whether a character is a standard blank character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a standard blank character.
*
* DEF_NO, if character is NOT a standard blank character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) states that "isblank() returns true only for
* the standard blank characters".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) defines "the standard blank characters" as
* the "space (' '), and horizontal tab ('\t')".
*********************************************************************************************************
*/
#define ASCII_IS_BLANK(c) ((((c) == ASCII_CHAR_SPACE) || ((c) == ASCII_CHAR_HT)) ? (DEF_YES) : (DEF_NO))
/*
*********************************************************************************************************
* ASCII_IS_SPACE()
*
* Description : Determine whether a character is a white-space character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a white-space character.
*
* DEF_NO, if character is NOT a white-space character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) states that "isspace() returns true only
* for the standard white-space characters".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) defines "the standard white-space characters"
* as the "space (' '), form feed ('\f'), new-line ('\n'), carriage return ('\r'),
* horizontal tab ('\t'), and vertical tab ('\v')".
*********************************************************************************************************
*/
#define ASCII_IS_SPACE(c) ((((c) == ASCII_CHAR_SPACE) || ((c) == ASCII_CHAR_CR) || \
((c) == ASCII_CHAR_LF ) || ((c) == ASCII_CHAR_FF) || \
((c) == ASCII_CHAR_HT ) || ((c) == ASCII_CHAR_VT)) ? (DEF_YES) : (DEF_NO))
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IS_PRINT()
*
* Description : Determine whether a character is a printing character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a printing character.
*
* DEF_NO, if character is NOT a printing character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.8.(2) states that "isprint() ... tests for any
* printing character including space (' ')".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
* ASCII character set, the printing characters are those whose values lie from
* 0x20 (space) through 0x7E (tilde)".
*********************************************************************************************************
*/
#define ASCII_IS_PRINT(c) ((((c) >= ASCII_CHAR_SPACE) && ((c) <= ASCII_CHAR_TILDE)) ? (DEF_YES) : (DEF_NO))
/*
*********************************************************************************************************
* ASCII_IS_GRAPH()
*
* Description : Determine whether a character is any printing character except a space character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a graphic character.
*
* DEF_NO, if character is NOT a graphic character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.6.(2) states that "isgraph() ... tests for any
* printing character except space (' ')".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
* ASCII character set, the printing characters are those whose values lie from
* 0x20 (space) through 0x7E (tilde)".
*********************************************************************************************************
*/
#define ASCII_IS_GRAPH(c) ((((c) >= ASCII_CHAR_EXCLAMATION_MARK) && ((c) <= ASCII_CHAR_TILDE)) ? (DEF_YES) : (DEF_NO))
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII_IS_PUNCT()
*
* Description : Determine whether a character is a punctuation character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a punctuation character.
*
* DEF_NO, if character is NOT a punctuation character.
*
* Caller(s) : Application.
*
* Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.9.(2) states that "ispunct() returns true for every
* printing character for which neither isspace() nor isalnum() is true".
*********************************************************************************************************
*/
#define ASCII_IS_PUNCT(c) ((((ASCII_IS_PRINT(c)) == DEF_YES) && \
((ASCII_IS_SPACE(c)) == DEF_NO ) && \
((ASCII_IS_ALPHA_NUM(c)) == DEF_NO )) ? (DEF_YES) : (DEF_NO))
/*
*********************************************************************************************************
* ASCII_IS_CTRL()
*
* Description : Determine whether a character is a control character.
*
* Argument(s) : c Character to examine.
*
* Return(s) : DEF_YES, if character is a control character.
*
* DEF_NO, if character is NOT a control character.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.4.(2) states that "iscntrl() ... tests for any
* control character".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US
* ASCII character set, ... the control characters are those whose values lie from
* 0 (NUL) through 0x1F (US), and the character 0x7F (DEL)".
*********************************************************************************************************
*/
#define ASCII_IS_CTRL(c) (((((CPU_INT08S)(c) >= ASCII_CHAR_NULL ) && ((c) <= ASCII_CHAR_IS1)) || \
((c) == ASCII_CHAR_DEL)) ? (DEF_YES) : (DEF_NO))
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII CHARACTER CASE MAPPING MACRO's
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ASCII_TO_LOWER()
*
* Description : Convert uppercase alphabetic character to its corresponding lowercase alphabetic character.
*
* Argument(s) : c Character to convert.
*
* Return(s) : Lowercase equivalent of 'c', if character 'c' is an uppercase character (see Note #1b1).
*
* Character 'c', otherwise (see Note #1b2).
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.1.(2) states that "tolower() ... converts an
* uppercase letter to a corresponding lowercase letter".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.2.1.(3) states that :
*
* (1) (A) "if the argument is a character for which isupper() is true and there are
* one or more corresponding characters ... for which islower() is true," ...
* (B) "tolower() ... returns one of the corresponding characters;" ...
*
* (2) "otherwise, the argument is returned unchanged."
*********************************************************************************************************
*/
#define ASCII_TO_LOWER(c) (((ASCII_IS_UPPER(c)) == DEF_YES) ? ((c) + (ASCII_CHAR_LATIN_LOWER_A - ASCII_CHAR_LATIN_UPPER_A)) : (c))
/*
*********************************************************************************************************
* ASCII_TO_UPPER()
*
* Description : Convert lowercase alphabetic character to its corresponding uppercase alphabetic character.
*
* Argument(s) : c Character to convert.
*
* Return(s) : Uppercase equivalent of 'c', if character 'c' is a lowercase character (see Note #1b1).
*
* Character 'c', otherwise (see Note #1b2).
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.2.(2) states that "toupper() ... converts a
* lowercase letter to a corresponding uppercase letter".
*
* (b) ISO/IEC 9899:TC2, Section 7.4.2.2.(3) states that :
*
* (1) (A) "if the argument is a character for which islower() is true and there are
* one or more corresponding characters ... for which isupper() is true," ...
* (B) "toupper() ... returns one of the corresponding characters;" ...
*
* (2) "otherwise, the argument is returned unchanged."
*********************************************************************************************************
*/
#define ASCII_TO_UPPER(c) (((ASCII_IS_LOWER(c)) == DEF_YES) ? ((c) - (ASCII_CHAR_LATIN_LOWER_A - ASCII_CHAR_LATIN_UPPER_A)) : (c))
/*$PAGE*/
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
CPU_BOOLEAN ASCII_IsAlpha (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsAlphaNum(CPU_CHAR c);
CPU_BOOLEAN ASCII_IsLower (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsUpper (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsDig (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsDigOct (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsDigHex (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsBlank (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsSpace (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsPrint (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsGraph (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsPunct (CPU_CHAR c);
CPU_BOOLEAN ASCII_IsCtrl (CPU_CHAR c);
CPU_CHAR ASCII_ToLower (CPU_CHAR c);
CPU_CHAR ASCII_ToUpper (CPU_CHAR c);
CPU_BOOLEAN ASCII_Cmp (CPU_CHAR c1,
CPU_CHAR c2);
/*$PAGE*/
/*
*********************************************************************************************************
* CONFIGURATION ERRORS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE END
*
* Note(s) : (1) See 'lib_ascii.h MODULE'.
*********************************************************************************************************
*/
#endif /* End of lib ascii module include. */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,283 @@
/*
*********************************************************************************************************
* uC/LIB
* CUSTOM LIBRARY MODULES
*
* (c) Copyright 2004-2012; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/LIB is provided in source form to registered licensees ONLY. It is
* illegal to distribute this source code to any third party unless you receive
* written permission by an authorized Micrium representative. Knowledge of
* the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*
* You can contact us at www.micrium.com.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* MATHEMATIC OPERATIONS
*
* Filename : lib_math.c
* Version : V1.37.01
* Programmer(s) : SR
* ITJ
*********************************************************************************************************
* Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
*
* (a) ALL standard library functions are implemented in the custom library modules :
*
* (1) \<Custom Library Directory>\lib_*.*
*
* (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
*
* where
* <Custom Library Directory> directory path for custom library software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (b) Product-specific library functions are implemented in individual products.
*
*********************************************************************************************************
* Notice(s) : (1) The Institute of Electrical and Electronics Engineers and The Open Group, have given
* us permission to reprint portions of their documentation. Portions of this text are
* reprinted and reproduced in electronic form from the IEEE Std 1003.1, 2004 Edition,
* Standard for Information Technology -- Portable Operating System Interface (POSIX),
* The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute
* of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any
* discrepancy between these versions and the original IEEE and The Open Group Standard,
* the original IEEE and The Open Group Standard is the referee document. The original
* Standard can be obtained online at http://www.opengroup.org/unix/online.html.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#define MICRIUM_SOURCE
#define LIB_MATH_MODULE
#include <lib_math.h>
/*$PAGE*/
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL TABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
RAND_NBR Math_RandSeedCur; /* Cur rand nbr seed. */
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/
/*$PAGE*/
/*
*********************************************************************************************************
* Math_Init()
*
* Description : (1) Initialize Mathematic Module :
*
* (a) Initialize random number seed value
*
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : (2) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that "if rand()
* is called before any calls to srand() are made, the same sequence shall be generated
* as when srand() is first called with a seed value of 1".
*********************************************************************************************************
*/
void Math_Init (void)
{
Math_RandSetSeed((RAND_NBR)RAND_SEED_INIT_VAL); /* See Note #2. */
}
/*$PAGE*/
/*
*********************************************************************************************************
* Math_RandSetSeed()
*
* Description : Set the current pseudo-random number generator seed.
*
* Argument(s) : seed Initial (or current) value to set for the pseudo-random number sequence.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : (1) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that "srand()
* ... uses the argument as a seed for a new sequence of pseudo-random numbers to be
* returned by subsequent calls to rand()".
*
* (2) 'Math_RandSeedCur' MUST always be accessed exclusively in critical sections.
*
* See also 'Math_Rand() Note #1b'.
*********************************************************************************************************
*/
void Math_RandSetSeed (RAND_NBR seed)
{
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
Math_RandSeedCur = seed;
CPU_CRITICAL_EXIT();
}
/*$PAGE*/
/*
*********************************************************************************************************
* Math_Rand()
*
* Description : Calculate the next pseudo-random number.
*
* Argument(s) : none.
*
* Return(s) : Next pseudo-random number in the sequence after 'Math_RandSeedCur'.
*
* Caller(s) : Application.
*
* Note(s) : (1) (a) The pseudo-random number generator is implemented as a Linear Congruential
* Generator (LCG).
*
* (b) The pseudo-random number generated is in the range [0, RAND_LCG_PARAM_M].
*
* See also 'Math_RandSeed() Note #1'.
*
* (2) (a) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that "rand()
* ... need not be reentrant ... [and] is not required to be thread-safe".
*
* (b) However, in order to implement Math_Rand() as re-entrant; 'Math_RandSeedCur' MUST
* always be accessed & updated exclusively in critical sections.
*
* See also 'Math_RandSeed() Note #2'.
*********************************************************************************************************
*/
RAND_NBR Math_Rand (void)
{
RAND_NBR seed;
RAND_NBR rand_nbr;
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
seed = Math_RandSeedCur;
rand_nbr = Math_RandSeed(seed);
Math_RandSeedCur = rand_nbr;
CPU_CRITICAL_EXIT();
return (rand_nbr);
}
/*$PAGE*/
/*
*********************************************************************************************************
* Math_RandSeed()
*
* Description : Calculate the next pseudo-random number.
*
* Argument(s) : seed Initial (or current) value for the pseudo-random number sequence.
*
* Return(s) : Next pseudo-random number in the sequence after 'seed'.
*
* Caller(s) : Math_Rand(),
* Application.
*
* Note(s) : (1) (a) BSD/ANSI-C implements rand() as a Linear Congruential Generator (LCG) :
*
* (A) random_number = [(a * random_number ) + b] modulo m
* n + 1 n
*
* where
* (1) (a) random_number Next random number to generate
* n+1
* (b) random_number Previous random number generated
* n
*
* (2) a = RAND_LCG_PARAM_A LCG multiplier
* (3) b = RAND_LCG_PARAM_B LCG incrementor
* (4) m = RAND_LCG_PARAM_M + 1 LCG modulus
*
* (b) The pseudo-random number generated is in the range [0, RAND_LCG_PARAM_M].
*
See also 'lib_math.h RANDOM NUMBER DEFINES Note #1b'.
*
* (2) (a) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that "rand()
* ... need not be reentrant ... [and] is not required to be thread-safe".
*
* (b) However, Math_RandSeed() is re-entrant since it calculates the next random number
* using ONLY local variables.
*********************************************************************************************************
*/
RAND_NBR Math_RandSeed (RAND_NBR seed)
{
RAND_NBR rand_nbr;
rand_nbr = (((RAND_NBR)RAND_LCG_PARAM_A * seed) + (RAND_NBR)RAND_LCG_PARAM_B) % ((RAND_NBR)RAND_LCG_PARAM_M + 1u);
return (rand_nbr);
}

View File

@@ -0,0 +1,230 @@
/*
*********************************************************************************************************
* uC/LIB
* CUSTOM LIBRARY MODULES
*
* (c) Copyright 2004-2012; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/LIB is provided in source form to registered licensees ONLY. It is
* illegal to distribute this source code to any third party unless you receive
* written permission by an authorized Micrium representative. Knowledge of
* the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*
* You can contact us at www.micrium.com.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* MATHEMATIC OPERATIONS
*
* Filename : lib_math.h
* Version : V1.37.01
* Programmer(s) : SR
* ITJ
*********************************************************************************************************
* Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
*
* (a) ALL standard library functions are implemented in the custom library modules :
*
* (1) \<Custom Library Directory>\lib_*.*
*
* (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
*
* where
* <Custom Library Directory> directory path for custom library software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (b) Product-specific library functions are implemented in individual products.
*
*********************************************************************************************************
* Notice(s) : (1) The Institute of Electrical and Electronics Engineers and The Open Group, have given
* us permission to reprint portions of their documentation. Portions of this text are
* reprinted and reproduced in electronic form from the IEEE Std 1003.1, 2004 Edition,
* Standard for Information Technology -- Portable Operating System Interface (POSIX),
* The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute
* of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any
* discrepancy between these versions and the original IEEE and The Open Group Standard,
* the original IEEE and The Open Group Standard is the referee document. The original
* Standard can be obtained online at http://www.opengroup.org/unix/online.html.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE
*
* Note(s) : (1) This mathematics library header file is protected from multiple pre-processor inclusion
* through use of the mathematics library module present pre-processor macro definition.
*********************************************************************************************************
*/
#ifndef LIB_MATH_MODULE_PRESENT /* See Note #1. */
#define LIB_MATH_MODULE_PRESENT
/*$PAGE*/
/*
*********************************************************************************************************
* INCLUDE FILES
*
* Note(s) : (1) The custom library software files are located in the following directories :
*
* (a) \<Custom Library Directory>\lib_*.*
*
* where
* <Custom Library Directory> directory path for custom library software
*
* (2) CPU-configuration software files are located in the following directories :
*
* (a) \<CPU-Compiler Directory>\cpu_*.*
* (b) \<CPU-Compiler Directory>\<cpu>\<compiler>\cpu*.*
*
* where
* <CPU-Compiler Directory> directory path for common CPU-compiler software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (3) Compiler MUST be configured to include as additional include path directories :
*
* (a) '\<Custom Library Directory>\' directory See Note #1a
*
* (b) (1) '\<CPU-Compiler Directory>\' directory See Note #2a
* (2) '\<CPU-Compiler Directory>\<cpu>\<compiler>\' directory See Note #2b
*
* (4) NO compiler-supplied standard library functions SHOULD be used.
*********************************************************************************************************
*/
#include <cpu.h>
#include <cpu_core.h>
#include <lib_def.h>
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef LIB_MATH_MODULE
#define LIB_MATH_EXT
#else
#define LIB_MATH_EXT extern
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* RANDOM NUMBER DEFINES
*
* Note(s) : (1) (a) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that "if rand()
* is called before any calls to srand() are made, the same sequence shall be generated
* as when srand() is first called with a seed value of 1".
*
* (b) (1) BSD/ANSI-C implements rand() as a Linear Congruential Generator (LCG) :
*
* (A) random_number = [(a * random_number ) + b] modulo m
* n + 1 n
*
* where
* (1) (a) random_number Next random number to generate
* n+1
* (b) random_number Previous random number generated
* n
* (c) random_number Initial random number seed
* 0 See also Note #1a
*
* (2) a = 1103515245 LCG multiplier
* (3) b = 12345 LCG incrementor
* (4) m = RAND_MAX + 1 LCG modulus See also Note #1b2
*
* (2) (A) IEEE Std 1003.1, 2004 Edition, Section 'rand() : DESCRIPTION' states that
* "rand() ... shall compute a sequence of pseudo-random integers in the range
* [0, {RAND_MAX}] with a period of at least 2^32".
*
* (B) However, BSD/ANSI-C 'stdlib.h' defines "RAND_MAX" as "0x7fffffff", or 2^31;
* which therefore limits the range AND period to no more than 2^31.
*********************************************************************************************************
*/
#define RAND_SEED_INIT_VAL 1u /* See Note #1a. */
#define RAND_LCG_PARAM_M 0x7FFFFFFFu /* See Note #1b2B. */
#define RAND_LCG_PARAM_A 1103515245u /* See Note #1b1A2. */
#define RAND_LCG_PARAM_B 12345u /* See Note #1b1A3. */
/*$PAGE*/
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* RANDOM NUMBER DATA TYPE
*********************************************************************************************************
*/
typedef CPU_INT32U RAND_NBR;
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
void Math_Init (void);
/* ------------------ RAND NBR FNCTS ------------------ */
void Math_RandSetSeed(RAND_NBR seed);
RAND_NBR Math_Rand (void);
RAND_NBR Math_RandSeed (RAND_NBR seed);
/*$PAGE*/
/*
*********************************************************************************************************
* CONFIGURATION ERRORS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE END
*
* Note(s) : (1) See 'lib_math.h MODULE'.
*********************************************************************************************************
*/
#endif /* End of lib math module include. */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,433 @@
/*
*********************************************************************************************************
* uC/LIB
* CUSTOM LIBRARY MODULES
*
* (c) Copyright 2004-2012; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/LIB is provided in source form to registered licensees ONLY. It is
* illegal to distribute this source code to any third party unless you receive
* written permission by an authorized Micrium representative. Knowledge of
* the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*
* You can contact us at www.micrium.com.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* ASCII STRING MANAGEMENT
*
* Filename : lib_str.h
* Version : V1.37.01
* Programmer(s) : ITJ
* JDH
*********************************************************************************************************
* Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software.
*
* (a) ALL standard library functions are implemented in the custom library modules :
*
* (1) \<Custom Library Directory>\lib_*.*
*
* (2) \<Custom Library Directory>\Ports\<cpu>\<compiler>\lib*_a.*
*
* where
* <Custom Library Directory> directory path for custom library software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (b) Product-specific library functions are implemented in individual products.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE
*
* Note(s) : (1) This string library header file is protected from multiple pre-processor inclusion through
* use of the string library module present pre-processor macro definition.
*********************************************************************************************************
*/
#ifndef LIB_STR_MODULE_PRESENT /* See Note #1. */
#define LIB_STR_MODULE_PRESENT
/*$PAGE*/
/*
*********************************************************************************************************
* ASCII STRING CONFIGURATION DEFINES
*
* Note(s) : (1) Some ASCII string configuration #define's MUST be available PRIOR to including any
* application configuration (see 'INCLUDE FILES Note #1a').
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* STRING FLOATING POINT DEFINES
*
* Note(s) : (1) (a) (1) The maximum accuracy for 32-bit floating-point numbers :
*
*
* Maximum Accuracy log [Internal-Base ^ (Number-Internal-Base-Digits)]
* 32-bit Floating-point Number = -----------------------------------------------------
* log [External-Base]
*
* log [2 ^ 24]
* = --------------
* log [10]
*
* < 7.225 Base-10 Digits
*
* where
* Internal-Base Internal number base of floating-
* point numbers (i.e. 2)
* External-Base External number base of floating-
* point numbers (i.e. 10)
* Number-Internal-Base-Digits Number of internal number base
* significant digits (i.e. 24)
*
* (2) Also, since some 32-bit floating-point calculations are converted to 32-bit
* unsigned numbers, the maximum accuracy is limited to the maximum accuracy
* for 32-bit unsigned numbers of 9 digits.
*
* (b) Some CPUs' &/or compilers' floating-point implementations MAY further reduce the
* maximum accuracy.
*********************************************************************************************************
*/
#define LIB_STR_FP_MAX_NBR_DIG_SIG_MIN 1u
#define LIB_STR_FP_MAX_NBR_DIG_SIG_MAX 9u /* See Note #1a2. */
#define LIB_STR_FP_MAX_NBR_DIG_SIG_DFLT 7u /* See Note #1a1. */
/*$PAGE*/
/*
*********************************************************************************************************
* INCLUDE FILES
*
* Note(s) : (1) The custom library software files are located in the following directories :
*
* (a) \<Your Product Application>\lib_cfg.h
*
* (b) \<Custom Library Directory>\lib_*.*
*
* where
* <Your Product Application> directory path for Your Product's Application
* <Custom Library Directory> directory path for custom library software
*
* (2) CPU-configuration software files are located in the following directories :
*
* (a) \<CPU-Compiler Directory>\cpu_*.*
* (b) \<CPU-Compiler Directory>\<cpu>\<compiler>\cpu*.*
*
* where
* <CPU-Compiler Directory> directory path for common CPU-compiler software
* <cpu> directory name for specific processor (CPU)
* <compiler> directory name for specific compiler
*
* (3) Compiler MUST be configured to include as additional include path directories :
*
* (a) '\<Your Product Application>\' directory See Note #1a
*
* (b) '\<Custom Library Directory>\' directory See Note #1b
*
* (c) (1) '\<CPU-Compiler Directory>\' directory See Note #2a
* (2) '\<CPU-Compiler Directory>\<cpu>\<compiler>\' directory See Note #2b
*
* (4) NO compiler-supplied standard library functions SHOULD be used.
*
* #### The reference to standard library header files SHOULD be removed once all custom
* library functions are implemented WITHOUT reference to ANY standard library function(s).
*
* See also 'STANDARD LIBRARY MACRO'S Note #1'.
*********************************************************************************************************
*/
#include <cpu.h>
#include <lib_def.h>
#include <lib_ascii.h>
#include <lib_cfg.h>
#if 0 /* See Note #4. */
#include <stdio.h>
#endif
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef LIB_STR_MODULE
#define LIB_STR_EXT
#else
#define LIB_STR_EXT extern
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* DEFAULT CONFIGURATION
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* STRING FLOATING POINT CONFIGURATION
*
* Note(s) : (1) Configure LIB_STR_CFG_FP_EN to enable/disable floating point string function(s).
*
* (2) Configure LIB_STR_CFG_FP_MAX_NBR_DIG_SIG to configure the maximum number of significant
* digits to calculate &/or display for floating point string function(s).
*
* See also 'STRING FLOATING POINT DEFINES Note #1'.
*********************************************************************************************************
*/
/* Configure floating point feature(s) [see Note #1] : */
#ifndef LIB_STR_CFG_FP_EN
#define LIB_STR_CFG_FP_EN DEF_DISABLED
/* DEF_DISABLED Floating point functions DISABLED */
/* DEF_ENABLED Floating point functions ENABLED */
#endif
/* Configure floating point feature(s)' number of ... */
/* ... significant digits (see Note #2). */
#ifndef LIB_STR_CFG_FP_MAX_NBR_DIG_SIG
#define LIB_STR_CFG_FP_MAX_NBR_DIG_SIG LIB_STR_FP_MAX_NBR_DIG_SIG_DFLT
#endif
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
#define STR_CR_LF "\r\n"
#define STR_LF_CR "\n\r"
#define STR_NEW_LINE STR_CR_LF
#define STR_PARENT_PATH ".."
#define STR_CR_LF_LEN (sizeof(STR_CR_LF) - 1)
#define STR_LF_CR_LEN (sizeof(STR_LF_CR) - 1)
#define STR_NEW_LINE_LEN (sizeof(STR_NEW_LINE) - 1)
#define STR_PARENT_PATH_LEN (sizeof(STR_PARENT_PATH) - 1)
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
/*$PAGE*/
/*
*********************************************************************************************************
* MACRO'S
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* STANDARD LIBRARY MACRO'S
*
* Note(s) : (1) NO compiler-supplied standard library functions SHOULD be used.
*
* #### The reference to standard memory functions SHOULD be removed once all custom library
* functions are implemented WITHOUT reference to ANY standard library function(s).
*
* See also 'INCLUDE FILES Note #3'.
*********************************************************************************************************
*/
/* See Note #1. */
#define Str_FmtPrint snprintf
#define Str_FmtScan sscanf
/*$PAGE*/
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
/* ------------------ STR LEN FNCTS ------------------ */
CPU_SIZE_T Str_Len (const CPU_CHAR *pstr);
CPU_SIZE_T Str_Len_N (const CPU_CHAR *pstr,
CPU_SIZE_T len_max);
/* ------------------ STR COPY FNCTS ------------------ */
CPU_CHAR *Str_Copy ( CPU_CHAR *pstr_dest,
const CPU_CHAR *pstr_src);
CPU_CHAR *Str_Copy_N ( CPU_CHAR *pstr_dest,
const CPU_CHAR *pstr_src,
CPU_SIZE_T len_max);
CPU_CHAR *Str_Cat ( CPU_CHAR *pstr_dest,
const CPU_CHAR *pstr_cat);
CPU_CHAR *Str_Cat_N ( CPU_CHAR *pstr_dest,
const CPU_CHAR *pstr_cat,
CPU_SIZE_T len_max);
/* ------------------ STR CMP FNCTS ------------------ */
CPU_INT16S Str_Cmp (const CPU_CHAR *p1_str,
const CPU_CHAR *p2_str);
CPU_INT16S Str_Cmp_N (const CPU_CHAR *p1_str,
const CPU_CHAR *p2_str,
CPU_SIZE_T len_max);
CPU_INT16S Str_CmpIgnoreCase (const CPU_CHAR *p1_str,
const CPU_CHAR *p2_str);
CPU_INT16S Str_CmpIgnoreCase_N(const CPU_CHAR *p1_str,
const CPU_CHAR *p2_str,
CPU_SIZE_T len_max);
/* ------------------ STR SRCH FNCTS ------------------ */
CPU_CHAR *Str_Char (const CPU_CHAR *pstr,
CPU_CHAR srch_char);
CPU_CHAR *Str_Char_N (const CPU_CHAR *pstr,
CPU_SIZE_T len_max,
CPU_CHAR srch_char);
CPU_CHAR *Str_Char_Last (const CPU_CHAR *pstr,
CPU_CHAR srch_char);
CPU_CHAR *Str_Char_Last_N (const CPU_CHAR *pstr,
CPU_SIZE_T len_max,
CPU_CHAR srch_char);
CPU_CHAR *Str_Char_Replace ( CPU_CHAR *pstr,
CPU_CHAR char_srch,
CPU_CHAR char_replace);
CPU_CHAR *Str_Char_Replace_N ( CPU_CHAR *pstr,
CPU_CHAR char_srch,
CPU_CHAR char_replace,
CPU_SIZE_T len_max);
CPU_CHAR *Str_Str (const CPU_CHAR *pstr,
const CPU_CHAR *pstr_srch);
CPU_CHAR *Str_Str_N (const CPU_CHAR *pstr,
const CPU_CHAR *pstr_srch,
CPU_SIZE_T len_max);
/*$PAGE*/
/* ------------------ STR FMT FNCTS ------------------ */
CPU_CHAR *Str_FmtNbr_Int32U ( CPU_INT32U nbr,
CPU_INT08U nbr_dig,
CPU_INT08U nbr_base,
CPU_CHAR lead_char,
CPU_BOOLEAN lower_case,
CPU_BOOLEAN nul,
CPU_CHAR *pstr);
CPU_CHAR *Str_FmtNbr_Int32S ( CPU_INT32S nbr,
CPU_INT08U nbr_dig,
CPU_INT08U nbr_base,
CPU_CHAR lead_char,
CPU_BOOLEAN lower_case,
CPU_BOOLEAN nul,
CPU_CHAR *pstr);
#if (LIB_STR_CFG_FP_EN == DEF_ENABLED)
CPU_CHAR *Str_FmtNbr_32 ( CPU_FP32 nbr,
CPU_INT08U nbr_dig,
CPU_INT08U nbr_dp,
CPU_CHAR lead_char,
CPU_BOOLEAN nul,
CPU_CHAR *pstr);
#endif
/* ----------------- STR PARSE FNCTS ------------------ */
CPU_INT32U Str_ParseNbr_Int32U(const CPU_CHAR *pstr,
CPU_CHAR **pstr_next,
CPU_INT08U nbr_base);
CPU_INT32S Str_ParseNbr_Int32S(const CPU_CHAR *pstr,
CPU_CHAR **pstr_next,
CPU_INT08U nbr_base);
/*$PAGE*/
/*
*********************************************************************************************************
* CONFIGURATION ERRORS
*********************************************************************************************************
*/
#ifndef LIB_STR_CFG_FP_EN
#error "LIB_STR_CFG_FP_EN not #define'd in 'lib_cfg.h'"
#error " [MUST be DEF_DISABLED] "
#error " [ || DEF_ENABLED ] "
#elif ((LIB_STR_CFG_FP_EN != DEF_DISABLED) && \
(LIB_STR_CFG_FP_EN != DEF_ENABLED ))
#error "LIB_STR_CFG_FP_EN illegally #define'd in 'lib_cfg.h'"
#error " [MUST be DEF_DISABLED] "
#error " [ || DEF_ENABLED ] "
#elif (LIB_STR_CFG_FP_EN == DEF_ENABLED)
#ifndef LIB_STR_CFG_FP_MAX_NBR_DIG_SIG
#error "LIB_STR_CFG_FP_MAX_NBR_DIG_SIG not #define'd in 'lib_cfg.h' "
#error " [MUST be >= LIB_STR_FP_MAX_NBR_DIG_SIG_MIN]"
#error " [ && <= LIB_STR_FP_MAX_NBR_DIG_SIG_MAX]"
#elif (DEF_CHK_VAL(LIB_STR_CFG_FP_MAX_NBR_DIG_SIG, \
LIB_STR_FP_MAX_NBR_DIG_SIG_MIN, \
LIB_STR_FP_MAX_NBR_DIG_SIG_MAX) != DEF_OK)
#error "LIB_STR_CFG_FP_MAX_NBR_DIG_SIG illegally #define'd in 'lib_cfg.h' "
#error " [MUST be >= LIB_STR_FP_MAX_NBR_DIG_SIG_MIN]"
#error " [ && <= LIB_STR_FP_MAX_NBR_DIG_SIG_MAX]"
#endif
#endif
/*
*********************************************************************************************************
* MODULE END
*
* Note(s) : (1) See 'lib_str.h MODULE'.
*********************************************************************************************************
*/
#endif /* End of lib str module include. */