A SERVICE OF

logo

Cypress CY3640 USB Starter Kit
User’s Guide
Cypress Semiconductor Ver 0.993
Page 20
;*************************************************
SysUnUsed:
push a
mov a,[gbSysInterruptMask]
ipret SysInterrupt
;//$PAGE
;*******************************************************************************
; main()
; @func Entry point after PowerOn, WatchDog timeout or WakeUp from sleeping.
; @comm Never returns
;*******************************************************************************
main:
; This portion of Main is only executed after a RESET (Power-On or USB)
; Setup data stack in high order RAM, just below EP0 FIFO
; It will grow down from here
mov a,70h ; USBEndP0FIFO
swap a,dsp
; Initialize both Ports high
mov a,FFh
iowr SysPort0 ; Port 0 Data reg
iowr SysPort1 ; Port 1 Data reg
; 1 on P13 is needed to make sure enumerate LED is off
; 1 on any port that needs to be an input
; Enable Pullups (0=enable)
mov a,0
iowr SysPort0PullUp
mov a,Button_Pin
iowr SysPort1PullUp ; 1 on P12 is needed to make sure GPIO interrupt
; occurs on LOW to HIGH transistion. This
; disables it's pull up
; Enable or disable interrupts on appropriate pins
mov a,0
iowr SysPort0IntEnable ; All pins irq's are disabled on Port 0
mov a,Button_Pin
iowr SysPort1IntEnable ; Enable P12, the button pin.
; No interrupts will occur until the device
; is enumerated. Then GPIO's will be enabled and
; we will allow P12 to generate interrupts
; Initialize timers
mov a,0
mov [gbSysTick1024us],a
mov [gbSysTick1024usRoll],a
; Initialize USB variables
mov a,0
mov [gbUSBValidRqsts],a ; No valid requests yet
mov [gbUSBSendSequence],a ; Start with a 0
mov [gbSysEnumerated],a ; Not enumerated
; Initialize LED
mov a,1 ; flag it for an update
mov [gbLEDBrightnessUpdate],a
mov a,FFh ; set for maximum brightness
mov [gbLEDBrightness],a
; Initialized Button
mov a,0
mov [gbButtonPushed],a ; Initial state of 0, no button pushed
; Initialize variables
mov a,0
mov [gbUSBSendBytes],a ; No bytes to send in FIFO buffers
mov [gbSuspendCount],a ; Reset bus activity to 0
mov [gbButtonDebounce],a ; We are not debouncing
; Set interrupt mask
mov a,SysIntTimer1024us | SysIntUSBEndP0