I'm working up a little "home-brew" ftp module. The issue I'm running into is I'm constructing it for two different PICs. (the 18F2620 and the 18F25K22).
One of these PICs has two USARTs (which is really cool).
So, I'm trying to set up a #define to set whether it's using USART1 or USART2, but I'm having trouble getting it to work. Thing is, I'm pretty sure it's doable, and I'm just lacking the syntax.
Here's what I've tried (unsuccessfully)
Code: Select all
#ifndef FTP
#define FTP
Module FTP
#if FTP_USART = USART
Include "USART.bas"
#elseif FTP_USART = USART2
Include "USART2.bas"
#else
#error FTP_USART, "Define a _VALID_ USART!!"
#endif
'the part above works fine
'the part below gives me grief, sometimes by throwing odd errors from the compiler in other, entirely unrelated parts of the code which aren't even in the module.
'--------------------------------=-=---------------------------------------
Public Function CommTimeout() As Boolean
'--------------------------------=-=---------------------------------------
Dim
TimeOut As Word
'---------------=-=---------------
TimeOut = 50000 '1/4 second in 10us bites.
If (FTP_USART.OERR = 1) Then FTP_USART.ClearOverrun() EndIf
While (FTP_USART.RCIF = 0 And TimeOut > 0)
Dec(TimeOut)
DelayUS(5)
Wend
If (TimeOut > 0) Then
CommTimeout = true
Else
CommTimeout = false
EndIf
End Function
#endif
Thanx in advance.