| |
showinfo.pwp
//-------------------------------------------------------------------------
//
// PicoWeb Project File for showinfo
//
//-------------------------------------------------------------------------
//
// application-specific preprocessor definitions
//
#define EEPROM_IP /* use file "ip" for default IP address */
#define NET_CONFIG_IP /* allow IP address reconfiguration via net */
#define ENABLE_WATCHDOG /* use Atmel watchdog timer hardware */
//#define DEBUGGER /* include debugger firmware */
#undef DEBUGGER
//#define CLOCK 8000000 /* processor clock rate */
#define CLOCK 7372000 /* processor clock rate */
#define BAUD_RATE 19200 /* serial port baud rate */
#define WEB_BLINK_LED /* will blink PicoWeb LED during Web page access */
//
// application-specific HTML and image file names
//
showinfo.htm // ii00 (default Web page)
pshow_ip.cgi
pshow_mac.cgi
pshow_ip_req.cgi
pshow_port_req.cgi
//
// included application-specific pcode and/or AVR assembly language follows
//
#avr_reset
;--------------------------------------------------------------------------
; this code is executed each time microcontroller is reset
;--------------------------------------------------------------------------
;
.data
hit_count:: .word 0 ; will reset with this value
.text
ser r16 ; pull-up on port B inputs
out portb,r16
#ifdef WEB_BLINK_LED
#define LED_ON cbi portd,LED_BIT /* turn LED on */
#define LED_OFF sbi portd,LED_BIT /* turn LED off */
#define PLED_ON pledon /* turn LED on with pcode */
#define PLED_OFF pledoff /* turn LED off with pcode */
.text
sbi DDRD,LED_BIT ; make LED driver pin an output
LED_OFF ; turn LED off
#else /* !WEB_BLINK_LED */
#define LED_ON
#define LED_OFF
#define PLED_ON
#define PLED_OFF
#endif /* !WEB_BLINK_LED */
#avr_slow
;--------------------------------------------------------------------------
; this code is executed each trip through "slow idle" loop (~1 sec period)
;--------------------------------------------------------------------------
;
#avr_fast
;--------------------------------------------------------------------------
; this code is executed each trip through "fast idle" loop
;--------------------------------------------------------------------------
;
#avr_asm
;--------------------------------------------------------------------------
; application-specific CGI pcode and AVR assembly routines go here
;--------------------------------------------------------------------------
;
.cseg
#ifdef WEB_BLINK_LED
.global pledon
pledon: pcode_routine 0
LED_ON
ret
.global pledoff
pledoff: pcode_routine 0
LED_OFF
ret
ledon::
pledon
pret
ledoff::
pledoff
pret
#else /* !WEB_BLINK_LED */
ledon::
pret
ledoff::
pret
#endif /* !WEB_BLINK_LED */
;--------------------------------------------------------------------------
.cseg
#define BUF buf
#define PBUF buf+6
#define COUNT buf+8
#define TEMP buf+10
pshow_ip::
pee2s BUF,eeprom_ip_addr,4 ; get PicoWeb IP address from EEPROM
pmovwi COUNT,4
pcall pshow_dotted
pret
pshow_nm::
pee2s BUF,eeprom_ip_addr+4,4 ; get PicoWeb netmask from EEPROM
pmovwi COUNT,4
pcall pshow_dotted
pret
pshow_gw::
pee2s BUF,eeprom_ip_gateway_addr,4 ; get default gateway from EEPROM
pmovwi COUNT,4
pcall pshow_dotted
pret
pshow_mac::
#ifndef BREADBOARD
pee2s BUF,eeprom_ether,6 ; get PicoWeb Ethernet address from EEPROM
#else
pmemcpy BUF,my_ether,6 ; get PicoWeb Ethernet address from SRAM
#endif
pmovwi COUNT,6
pcall pshow_dotted
pret
pshow_ip_req::
pr2s BUF,IP_SRCADDR,4 ; get source IP address from request packet
pmovwi COUNT,4
pcall pshow_dotted
pret
pshow_port_req::
pr2s BUF,TCP_SP,2 ; get source TCP port from request packet
pprintnuwi [swap BUF]
pret
pshow_dotted: ; print IP/MAC address ("dotted notation")
pclrw TEMP
pmovwi PBUF,buf
1:
pmovb TEMP,[PBUF]
pprintnuwi [TEMP]
pincw PBUF
pdecw COUNT
pjumpeq 2f
pputc '.'
pjump 1b
2:
pret
pshow_hits::
pincw hit_count ; bump hit counter
pmovwi BUF,[hit_count] ; move into BUF
pprintswi [BUF] ; output as decimal ascii
pret
pshow_clock::
pmovwi BUF,CLOCK/1000 ; move clock rate/1000 into BUF
pprintswi [BUF] ; output as decimal ascii
pret
pshow_baud::
#ifdef SERIAL_FULL_PARITY
pmovwi BUF,[baud_rate] ; move baud rate/100 into BUF
#else
pmovwi BUF,BAUD_RATE/100 ; move constant baud rate/100 into BUF
#endif
pprintswi [BUF] ; output as decimal ascii
pret
#define BIT buf
#define PORT buf+2
#define CNT buf+4
#define ONE buf+6
#define ZERO buf+7
pshow_port::
pmovbi ZERO,'0'
pmovbi ONE,'1'
pshow_port1:
pmovwi PORT,[psetparm_parm] ; get port I/O address
paddwi PORT,0x20 ; offset to memory address
pmovw PORT,[PORT] ; get contents of I/O port
pmovwi CNT,8 ; loopthru 8 bits
1:
pputc ' ' ; output leading blank
pmovwi BIT,[PORT] ; get MSB
pandwi BIT,0x80 ; mask for MSB
pjumpeq 2f ; skip ahead of 0
pputcb ONE ; non-zero...output a 1
pjump 3f
2:
pputcb ZERO ; zero...output a 0
3:
pshnw PORT,1 ; shift next bit into MSB
pdecw CNT ; decrement count
pjumpne 1b ; back if not yet done
pret
pshow_dir::
pmovbi ZERO,'I'
pmovbi ONE,'O'
pjump pshow_port1
#undef PORT buf
#undef BIT buf
#undef CNT buf
Back
|
|
|