Published using Google Docs
( QuickStart.fth )
Updated automatically every 5 minutes

TACHYON

[~

FORGET QuickStart.fth

pub QuickStart.fth                ." QuickStart + W5200 HARDWARE DEFINITIONS 140131.2130 " ;

{

DESCRIPTION

These are the header files that define the functions of the pins plus any other special functions needed for the QuickStart boards. Although these definitions are not strictly required they do simplify integration of the various Tachyon Forth modules which will be automatically configured to run on the QuickStart

}

( QuickStart and W5200 for QuickStart boards )

( P8X32A PINOUTS )

( PIN MASK NAME               HDR2X20     DESCRIPTION ) 

#P0         |< == S9                '' Pin 1        S9 through 100K

#P1         |< == S8                '' Pin 2        S8

#P2         |< == S7                '' Pin 3        S7

#P3         |< == S6                '' Pin 4        S6

#P4         |< == S5                '' Pin 5        S5

#P5         |< == S4                '' Pin 6        S4

#P6         |< == S3                '' Pin 7        S3

#P7         |< == S2                '' Pin 8        S2

'' * SD CARD SPI *

#P8         |< == &SDDO             '' Pin 9        Data from SDCARD        S/D input

#P9         |< == &SDCK             '' Pin 10        SDCARD clock        S/D resistor

#P10        |< == &SDDI             '' Pin 11        Data to SDCARD

#P11        |< == &SDCS             '' Pin 12        SDCARD chip select (cut pullup for card detect)

'' * WIZnet W5200 SPI *

#P12        |< == &WNCK             '' Pin 13        W5200 clock

#P13        |< == &WNDO             '' Pin 14        MISO from W5200

#P14        |< == &WNDI             '' Pin 15        MOSI to W5200

#P15        |< == &WNCS             '' Pin 16        W5200 chip select

'' * LEDS *

#P16        |< == LED1              '' Pin 17        D1 LED buffered (all blue!)

#P17        |< == LED2              '' Pin 18        D2 LED

#P18        |< == LED3              '' Pin 19        D3 LED

#P19        |< == LED4              '' Pin 20        D4 LED

#P20        |< == LED5              '' Pin 21        D5 LED

#P21        |< == LED6              '' Pin 22        D6 LED

#P22        |< == LED7              '' Pin 23        D7 LED

#P23        |< == LED8              '' Pin 24        D8 LED

'' * WIZnet W5200 control signals *

#P24        |< == &WNPWDN           '' Pin 25        W5200 Power down

#P25        |< == &WNINT            '' Pin 26        W5200 Interrupt

#P26        |< == &WNRST            '' Pin 27        W5200 reset

#P27        |< == PIN28             '' Pin 28

( LEDS )

\ do what needs to be done to turn off all the LEDs

pub !LEDS                   LED1 8 MASKS OUTCLR ;

pub ERRORLED ( on/off -- )                LED5 OUT ;

pub LANLED ( on/off -- )                LED4 OUT ;

pub SDERRLED ( on/off -- )                LED3 OUT ;

pub SDBSYLED ( on/off -- )                LED2 OUT ;

pub READYLED ( on/off -- )                LED1 OUT ;

pub WRESET ( on/off -- )        NOT &WNRST OUT ;

pub WPWRDN ( on/off )                &WNPWDN OUT ;

( TOUCH SWITCH INPUTS )

WORD touch                \ touch sensitivity

#1000 touch W!        \ set default

\ Read a touch pin input

\ Usage: S9 PRESSED? IF ." Yep, it's pressed " BELL THEN

pub PRESSED? ( pin# -- flg )

    DUP OUTSET DUP INPUTS touch W@ us IN NOT

    ;

( QuickStart board where 8 inputs are scanned and considered valid if active for 32 samples )

BYTE touchs #31 ALLOT

pub TOUCH@ ( -- pins )

    $FF DUP OUTSET INPUTS #500 us P@ INVERT $FF AND            \ Pulse the pins and read state after a delay

    touchs DUP 1+ #31 <CMOVE                                    \ make room for the new entry (shift method)

    touchs C!                                            \ update buffer

    $FF touchs #32 ADO I C@ AND LOOP                            \ Calculate filtered result

    ;

\ ----- RTC has been tested

( S-35390A RTC )

$60        == @rtc                \ S-35390A RTC "8-bit" I2C ADDRESS - modified with sub-address C2C1C0 for command (rather non-I2C)

DOUBLE rtcbuf

\ Read first 8 timekeeping bytes of RTC into rtcbuf - L

pub RDRTC

        I2CSTART @rtc 5 + I2C!                                                \ sub-address RTC date and time (7 byte seqential read YMDWHMS)

        7 FOR 0 I2C@ #24 REV rtcbuf 1- IX + C! NEXT                 \ read 7 bytes but write to buffer in reverse order SMHWDMY

        1 I2C@ DROP                                                                \ one dummy nak read

        I2CSTOP

        ;  

\ Write first 8 timekeeping bytes of RTC from rtcbuf

pub WRRTC

        I2CSTART @rtc 4 + I2C!                                                \ sub-address RTC data and time (7 byte sequential write)

        7 FOR rtcbuf 1- IX + C@ #24 REV I2C! NEXT                                \ Write year first

        I2CSTOP

        ;

pub TIME@ ( -- $hhmmss ) \ read time in bcd format

        RDRTC rtcbuf @

        ;

pub DATE@ ( -- $yymmdd ) \ read international date in bcd format

        RDRTC rtcbuf 4 + @

        ;

pub TIME! ( $hh.mm.ss -- ) \ write time in bcd format

        0

pri RTC!

        rtcbuf + ! WRRTC

        ;

\ Usage: $130630 DATE! \ set the date to the 30th June 2013

pub DATE! ( $yy.mm.dd -- )

        4 RTC!

        ;

pub .TIME                 TIME@ L>W .BYTE ." :" W>B .BYTE ." :" .BYTE ;

\ Print date in international format YYYY/MM/DD (otherwise 1/12/2013 could be 1st of December or 12th of January)

pub .DATE                DATE@ L>W ." 20" .BYTE ." /" W>B .BYTE ." /" .BYTE ;                

pub .DT                .DATE SPACE .TIME ;        

\ Do what we need to do to init this pcb

pub !PCB

         !LEDS ON READYLED

        ;

" QuickStart" 0 STRING PCB$

#40000         == PCB

]~

END

?BACKUP