diff --git a/src/ZigUP/CC2530DB/ZigUP.ewp b/src/ZigUP/CC2530DB/ZigUP.ewp index 340eb19..b1cd256 100755 --- a/src/ZigUP/CC2530DB/ZigUP.ewp +++ b/src/ZigUP/CC2530DB/ZigUP.ewp @@ -4650,9 +4650,78 @@ App + + $PROJ_DIR$\..\Source\adc.c + + + $PROJ_DIR$\..\Source\adc.h + + + $PROJ_DIR$\..\Source\bitmasks.h + + + $PROJ_DIR$\..\Source\delay.c + + + $PROJ_DIR$\..\Source\delay.h + + + $PROJ_DIR$\..\Source\dht22.c + + + $PROJ_DIR$\..\Source\dht22.h + + + $PROJ_DIR$\..\Source\ds18b20.c + + + $PROJ_DIR$\..\Source\ds18b20.h + + + $PROJ_DIR$\..\Source\global.c + + + $PROJ_DIR$\..\Source\global.h + + + $PROJ_DIR$\..\Source\interrupts.c + + + $PROJ_DIR$\..\Source\interrupts.h + + + $PROJ_DIR$\..\Source\led.c + + + $PROJ_DIR$\..\Source\led.h + $PROJ_DIR$\..\Source\OSAL_ZigUP.c + + $PROJ_DIR$\..\Source\random.c + + + $PROJ_DIR$\..\Source\random.h + + + $PROJ_DIR$\..\Source\uart.c + + + $PROJ_DIR$\..\Source\uart.h + + + $PROJ_DIR$\..\Source\utils.c + + + $PROJ_DIR$\..\Source\utils.h + + + $PROJ_DIR$\..\Source\ws2812.c + + + $PROJ_DIR$\..\Source\ws2812.h + $PROJ_DIR$\..\Source\zcl_zigup.c diff --git a/src/ZigUP/CC2530DB/ZigUP.ewt b/src/ZigUP/CC2530DB/ZigUP.ewt new file mode 100755 index 0000000..a03344c --- /dev/null +++ b/src/ZigUP/CC2530DB/ZigUP.ewt @@ -0,0 +1,5034 @@ + + + 3 + + CoordinatorEB + + 8051 + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RouterEB + + 8051 + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EndDeviceEB + + 8051 + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RouterZLight + + 8051 + + 1 + + C-STAT + 261 + + 261 + + 0 + + 1 + 600 + 1 + 2 + 0 + 1 + 100 + + + 1.5.4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + App + + $PROJ_DIR$\..\Source\adc.c + + + $PROJ_DIR$\..\Source\adc.h + + + $PROJ_DIR$\..\Source\bitmasks.h + + + $PROJ_DIR$\..\Source\delay.c + + + $PROJ_DIR$\..\Source\delay.h + + + $PROJ_DIR$\..\Source\dht22.c + + + $PROJ_DIR$\..\Source\dht22.h + + + $PROJ_DIR$\..\Source\ds18b20.c + + + $PROJ_DIR$\..\Source\ds18b20.h + + + $PROJ_DIR$\..\Source\global.c + + + $PROJ_DIR$\..\Source\global.h + + + $PROJ_DIR$\..\Source\interrupts.c + + + $PROJ_DIR$\..\Source\interrupts.h + + + $PROJ_DIR$\..\Source\led.c + + + $PROJ_DIR$\..\Source\led.h + + + $PROJ_DIR$\..\Source\OSAL_ZigUP.c + + + $PROJ_DIR$\..\Source\random.c + + + $PROJ_DIR$\..\Source\random.h + + + $PROJ_DIR$\..\Source\uart.c + + + $PROJ_DIR$\..\Source\uart.h + + + $PROJ_DIR$\..\Source\utils.c + + + $PROJ_DIR$\..\Source\utils.h + + + $PROJ_DIR$\..\Source\ws2812.c + + + $PROJ_DIR$\..\Source\ws2812.h + + + $PROJ_DIR$\..\Source\zcl_zigup.c + + + $PROJ_DIR$\..\Source\zcl_zigup.h + + + $PROJ_DIR$\..\Source\zcl_zigup_data.c + + + + HAL + + Common + + $PROJ_DIR$\..\..\..\..\..\Components\hal\common\hal_assert.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\common\hal_drivers.c + + + + Include + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_adc.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_assert.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_board.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_defs.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_drivers.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_flash.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_key.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_lcd.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_led.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_sleep.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_timer.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\include\hal_uart.h + + + + Target + + CC2530EB + + Config + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_board_cfg.h + + + + Drivers + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_adc.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_dma.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_flash.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_key.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_lcd.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_led.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_sleep.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_startup.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_timer.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_uart.c + + + + Includes + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_aes.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_ccm.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_dma.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_mcu.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530EB\hal_types.h + + + + + ZLIGHT + + Config + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_board_cfg.h + + + + Drivers + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_adc.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_dma.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_flash.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_key.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_lcd.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_led.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_sleep.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_startup.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_timer.c + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_uart.c + + + + Include + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_aes.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_ccm.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_dma.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_mcu.h + + + $PROJ_DIR$\..\..\..\..\..\Components\hal\target\CC2530PMP4712\hal_types.h + + + + + + + MAC + + High Level + + $PROJ_DIR$\..\..\..\..\..\Components\mac\high_level\mac_cfg.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\high_level\mac_high_level.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\high_level\mac_pib.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\high_level\mac_pib.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\high_level\mac_spec.h + + + + Include + + $PROJ_DIR$\..\..\..\..\..\Components\mac\include\mac_api.h + + + + Low Level + + Common + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_assert.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_autopend.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_autopend.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_backoff_timer.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_backoff_timer.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_low_level.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_low_level.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_radio.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_radio.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_rx.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_rx.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_rx_onoff.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_rx_onoff.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_sleep.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_sleep.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_tx.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\mac_tx.h + + + + System + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_csp_tx.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_csp_tx.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_mcu.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_mcu.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_mem.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_mem.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_radio_defs.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_radio_defs.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mac\low_level\srf04\single_chip\mac_rffrontend.c + + + + + + MT + + $PROJ_DIR$\..\..\..\..\..\Components\mt\DebugTrace.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\DebugTrace.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_AF.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_AF.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_APP.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_APP.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_DEBUG.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_DEBUG.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_NWK.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_NWK.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_RPC.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_SAPI.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_SAPI.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_SYS.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_SYS.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_TASK.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_TASK.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_UART.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_UART.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_UTIL.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_UTIL.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_VERSION.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_VERSION.h + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_ZDO.c + + + $PROJ_DIR$\..\..\..\..\..\Components\mt\MT_ZDO.h + + + + NWK + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\AddrMgr.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\APS.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\aps_frag.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\aps_groups.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\aps_util.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\APSMEDE.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\AssocList.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\BindingTable.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\BindingTable.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\NLMEDE.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\nwk.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\nwk_bufs.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\nwk_globals.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\nwk_globals.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\nwk_util.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\reflecttrack.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\rtg.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\stub_aps.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\nwk\stub_aps.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\sys\ZDiags.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\sys\ZDiags.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\sys\ZGlobals.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\sys\ZGlobals.h + + + + OSAL + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\comdef.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\common\OSAL.c + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\OSAL.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\common\OSAL_Clock.c + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\OSAL_Clock.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\mcu\cc2530\OSAL_Math.s51 + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\common\OSAL_Memory.c + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\OSAL_Memory.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\mcu\cc2530\OSAL_Nv.c + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\OSAL_Nv.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\common\OSAL_PwrMgr.c + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\OSAL_PwrMgr.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\OSAL_Tasks.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\common\OSAL_Timers.c + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\OSAL_Timers.h + + + $PROJ_DIR$\..\..\..\..\..\Components\osal\include\ZComDef.h + + + + Profile + + $PROJ_DIR$\..\..\..\..\..\Components\stack\af\AF.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\af\AF.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_diagnostic.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_diagnostic.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_ezmode.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_ezmode.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_general.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_general.h + + + $PROJ_DIR$\..\..\Source\zcl_ha.c + + + $PROJ_DIR$\..\..\Source\zcl_ha.h + + + + Security + + $PROJ_DIR$\..\..\..\..\..\Components\stack\sec\ssp.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\sec\ssp_hash.h + + + + Services + + $PROJ_DIR$\..\..\..\..\..\Components\services\saddr\saddr.c + + + $PROJ_DIR$\..\..\..\..\..\Components\services\saddr\saddr.h + + + + Tools + + $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8w2530.xcl + + + $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wConfig.cfg + + + $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wCoord.cfg + + + $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wEndev.cfg + + + $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wRouter.cfg + + + $PROJ_DIR$\..\..\..\Tools\CC2530DB\f8wZCL.cfg + + + + ZDO + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDApp.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDApp.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDConfig.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDConfig.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDNwkMgr.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDNwkMgr.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDObject.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDObject.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDProfile.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDProfile.h + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDSecMgr.c + + + $PROJ_DIR$\..\..\..\..\..\Components\stack\zdo\ZDSecMgr.h + + + + ZMac + + $PROJ_DIR$\..\..\..\..\..\Components\zmac\f8w\zmac.c + + + $PROJ_DIR$\..\..\..\..\..\Components\zmac\ZMAC.h + + + $PROJ_DIR$\..\..\..\..\..\Components\zmac\f8w\zmac_cb.c + + + $PROJ_DIR$\..\..\..\..\..\Components\zmac\f8w\zmac_internal.h + + + + ZMain + + $PROJ_DIR$\..\..\..\ZMain\TI2530DB\chipcon_cstartup.s51 + + + $PROJ_DIR$\..\..\..\ZMain\TI2530DB\OnBoard.c + + + $PROJ_DIR$\..\..\..\ZMain\TI2530DB\OnBoard.h + + + $PROJ_DIR$\..\..\..\ZMain\TI2530DB\ZMain.c + + + diff --git a/src/ZigUP/Source/OSAL_ZigUP.c b/src/ZigUP/Source/OSAL_ZigUP.c index bac920f..6eea637 100755 --- a/src/ZigUP/Source/OSAL_ZigUP.c +++ b/src/ZigUP/Source/OSAL_ZigUP.c @@ -1,7 +1,3 @@ -/********************************************************************* - * INCLUDES - */ - #include "ZComDef.h" #include "hal_drivers.h" #include "OSAL.h" @@ -24,9 +20,6 @@ #include "zcl_zigup.h" -/********************************************************************* - * GLOBAL VARIABLES - */ // The order in this table must be identical to the task initialization calls below in osalInitTask. const pTaskEventHandlerFn tasksArr[] = { @@ -51,10 +44,6 @@ const pTaskEventHandlerFn tasksArr[] = { const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] ); uint16 *tasksEvents; -/********************************************************************* - * FUNCTIONS - *********************************************************************/ - /********************************************************************* * @fn osalInitTasks * diff --git a/src/ZigUP/Source/adc.c b/src/ZigUP/Source/adc.c new file mode 100755 index 0000000..d77e835 --- /dev/null +++ b/src/ZigUP/Source/adc.c @@ -0,0 +1,59 @@ +#include "ZComDef.h" +#include "onboard.h" +#include "bitmasks.h" +#include "adc.h" + +uint16 ADC_Read(void) +{ + int16 result = 0; + ADCCON3 = b00110000; // internal reference, decimation 512, channel 0, start conversation + while (!(ADCCON1 & (1<<7))); // wait for conversation to finish + result = (uint16)ADCL; + result |= (uint16)(ADCH << 8); + if (result < 0) result = 0; + result >>= 2; + return result; +} + +uint16 ADC_Read_Avg(void) +{ + uint32 result = 0; + for (uint8 i=0; i<32; i++) result += ADC_Read(); + return (uint16)(result / 32); +} + +float ADC_GetVoltage(void) +{ + return ADC_Read_Avg() * 0.003949905; +} + +uint16 ADC_Temperature(void) +{ + int16 result = 0; + ADCCON3 = b00111110; // internal reference, decimation 512, temperature, start conversation + while (!(ADCCON1 & (1<<7))); // wait for conversation to finish + result = (uint16)ADCL; + result |= (uint16)(ADCH << 8); + if (result < 0) result = 0; + result >>= 2; + return result; +} + +uint16 ADC_Temperature_Avg(void) +{ + TR0 = 1; // connect the temperature sensor to the SOC_ADC + ATEST = 1; // Enables the temperature sensor + + uint32 result = 0; + for (uint8 i=0; i<32; i++) result += ADC_Temperature(); + + ATEST = 0; // Disables the temperature sensor + TR0 = 0; // disconnect the temperature sensor from the SOC_ADC + + return (uint16)(result / 32); +} + +float ADC_GetTemperature(void) +{ + return ADC_Temperature_Avg() * 0.0556 - 303.89; +} diff --git a/src/ZigUP/Source/adc.h b/src/ZigUP/Source/adc.h new file mode 100755 index 0000000..eef9e6e --- /dev/null +++ b/src/ZigUP/Source/adc.h @@ -0,0 +1,6 @@ +uint16 ADC_Read(void); +uint16 ADC_Read_Avg(void); +float ADC_GetVoltage(void); +uint16 ADC_Temperature(void); +uint16 ADC_Temperature_Avg(void); +float ADC_GetTemperature(void); diff --git a/src/ZigUP/Source/bitmasks.h b/src/ZigUP/Source/bitmasks.h new file mode 100755 index 0000000..97e4f93 --- /dev/null +++ b/src/ZigUP/Source/bitmasks.h @@ -0,0 +1,256 @@ +#define b00000000 0x00 +#define b00000001 0x01 +#define b00000010 0x02 +#define b00000011 0x03 +#define b00000100 0x04 +#define b00000101 0x05 +#define b00000110 0x06 +#define b00000111 0x07 +#define b00001000 0x08 +#define b00001001 0x09 +#define b00001010 0x0a +#define b00001011 0x0b +#define b00001100 0x0c +#define b00001101 0x0d +#define b00001110 0x0e +#define b00001111 0x0f +#define b00010000 0x10 +#define b00010001 0x11 +#define b00010010 0x12 +#define b00010011 0x13 +#define b00010100 0x14 +#define b00010101 0x15 +#define b00010110 0x16 +#define b00010111 0x17 +#define b00011000 0x18 +#define b00011001 0x19 +#define b00011010 0x1a +#define b00011011 0x1b +#define b00011100 0x1c +#define b00011101 0x1d +#define b00011110 0x1e +#define b00011111 0x1f +#define b00100000 0x20 +#define b00100001 0x21 +#define b00100010 0x22 +#define b00100011 0x23 +#define b00100100 0x24 +#define b00100101 0x25 +#define b00100110 0x26 +#define b00100111 0x27 +#define b00101000 0x28 +#define b00101001 0x29 +#define b00101010 0x2a +#define b00101011 0x2b +#define b00101100 0x2c +#define b00101101 0x2d +#define b00101110 0x2e +#define b00101111 0x2f +#define b00110000 0x30 +#define b00110001 0x31 +#define b00110010 0x32 +#define b00110011 0x33 +#define b00110100 0x34 +#define b00110101 0x35 +#define b00110110 0x36 +#define b00110111 0x37 +#define b00111000 0x38 +#define b00111001 0x39 +#define b00111010 0x3a +#define b00111011 0x3b +#define b00111100 0x3c +#define b00111101 0x3d +#define b00111110 0x3e +#define b00111111 0x3f +#define b01000000 0x40 +#define b01000001 0x41 +#define b01000010 0x42 +#define b01000011 0x43 +#define b01000100 0x44 +#define b01000101 0x45 +#define b01000110 0x46 +#define b01000111 0x47 +#define b01001000 0x48 +#define b01001001 0x49 +#define b01001010 0x4a +#define b01001011 0x4b +#define b01001100 0x4c +#define b01001101 0x4d +#define b01001110 0x4e +#define b01001111 0x4f +#define b01010000 0x50 +#define b01010001 0x51 +#define b01010010 0x52 +#define b01010011 0x53 +#define b01010100 0x54 +#define b01010101 0x55 +#define b01010110 0x56 +#define b01010111 0x57 +#define b01011000 0x58 +#define b01011001 0x59 +#define b01011010 0x5a +#define b01011011 0x5b +#define b01011100 0x5c +#define b01011101 0x5d +#define b01011110 0x5e +#define b01011111 0x5f +#define b01100000 0x60 +#define b01100001 0x61 +#define b01100010 0x62 +#define b01100011 0x63 +#define b01100100 0x64 +#define b01100101 0x65 +#define b01100110 0x66 +#define b01100111 0x67 +#define b01101000 0x68 +#define b01101001 0x69 +#define b01101010 0x6a +#define b01101011 0x6b +#define b01101100 0x6c +#define b01101101 0x6d +#define b01101110 0x6e +#define b01101111 0x6f +#define b01110000 0x70 +#define b01110001 0x71 +#define b01110010 0x72 +#define b01110011 0x73 +#define b01110100 0x74 +#define b01110101 0x75 +#define b01110110 0x76 +#define b01110111 0x77 +#define b01111000 0x78 +#define b01111001 0x79 +#define b01111010 0x7a +#define b01111011 0x7b +#define b01111100 0x7c +#define b01111101 0x7d +#define b01111110 0x7e +#define b01111111 0x7f +#define b10000000 0x80 +#define b10000001 0x81 +#define b10000010 0x82 +#define b10000011 0x83 +#define b10000100 0x84 +#define b10000101 0x85 +#define b10000110 0x86 +#define b10000111 0x87 +#define b10001000 0x88 +#define b10001001 0x89 +#define b10001010 0x8a +#define b10001011 0x8b +#define b10001100 0x8c +#define b10001101 0x8d +#define b10001110 0x8e +#define b10001111 0x8f +#define b10010000 0x90 +#define b10010001 0x91 +#define b10010010 0x92 +#define b10010011 0x93 +#define b10010100 0x94 +#define b10010101 0x95 +#define b10010110 0x96 +#define b10010111 0x97 +#define b10011000 0x98 +#define b10011001 0x99 +#define b10011010 0x9a +#define b10011011 0x9b +#define b10011100 0x9c +#define b10011101 0x9d +#define b10011110 0x9e +#define b10011111 0x9f +#define b10100000 0xa0 +#define b10100001 0xa1 +#define b10100010 0xa2 +#define b10100011 0xa3 +#define b10100100 0xa4 +#define b10100101 0xa5 +#define b10100110 0xa6 +#define b10100111 0xa7 +#define b10101000 0xa8 +#define b10101001 0xa9 +#define b10101010 0xaa +#define b10101011 0xab +#define b10101100 0xac +#define b10101101 0xad +#define b10101110 0xae +#define b10101111 0xaf +#define b10110000 0xb0 +#define b10110001 0xb1 +#define b10110010 0xb2 +#define b10110011 0xb3 +#define b10110100 0xb4 +#define b10110101 0xb5 +#define b10110110 0xb6 +#define b10110111 0xb7 +#define b10111000 0xb8 +#define b10111001 0xb9 +#define b10111010 0xba +#define b10111011 0xbb +#define b10111100 0xbc +#define b10111101 0xbd +#define b10111110 0xbe +#define b10111111 0xbf +#define b11000000 0xc0 +#define b11000001 0xc1 +#define b11000010 0xc2 +#define b11000011 0xc3 +#define b11000100 0xc4 +#define b11000101 0xc5 +#define b11000110 0xc6 +#define b11000111 0xc7 +#define b11001000 0xc8 +#define b11001001 0xc9 +#define b11001010 0xca +#define b11001011 0xcb +#define b11001100 0xcc +#define b11001101 0xcd +#define b11001110 0xce +#define b11001111 0xcf +#define b11010000 0xd0 +#define b11010001 0xd1 +#define b11010010 0xd2 +#define b11010011 0xd3 +#define b11010100 0xd4 +#define b11010101 0xd5 +#define b11010110 0xd6 +#define b11010111 0xd7 +#define b11011000 0xd8 +#define b11011001 0xd9 +#define b11011010 0xda +#define b11011011 0xdb +#define b11011100 0xdc +#define b11011101 0xdd +#define b11011110 0xde +#define b11011111 0xdf +#define b11100000 0xe0 +#define b11100001 0xe1 +#define b11100010 0xe2 +#define b11100011 0xe3 +#define b11100100 0xe4 +#define b11100101 0xe5 +#define b11100110 0xe6 +#define b11100111 0xe7 +#define b11101000 0xe8 +#define b11101001 0xe9 +#define b11101010 0xea +#define b11101011 0xeb +#define b11101100 0xec +#define b11101101 0xed +#define b11101110 0xee +#define b11101111 0xef +#define b11110000 0xf0 +#define b11110001 0xf1 +#define b11110010 0xf2 +#define b11110011 0xf3 +#define b11110100 0xf4 +#define b11110101 0xf5 +#define b11110110 0xf6 +#define b11110111 0xf7 +#define b11111000 0xf8 +#define b11111001 0xf9 +#define b11111010 0xfa +#define b11111011 0xfb +#define b11111100 0xfc +#define b11111101 0xfd +#define b11111110 0xfe +#define b11111111 0xff diff --git a/src/ZigUP/Source/delay.c b/src/ZigUP/Source/delay.c new file mode 100755 index 0000000..0c410b5 --- /dev/null +++ b/src/ZigUP/Source/delay.c @@ -0,0 +1,18 @@ +#include "ZComDef.h" +#include "delay.h" + +void _delay_us(uint16 microSecs) +{ + while(microSecs--) + { + asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); + } +} + +void _delay_ms(uint16 milliSecs) +{ + while(milliSecs--) + { + _delay_us(1000); + } +} diff --git a/src/ZigUP/Source/delay.h b/src/ZigUP/Source/delay.h new file mode 100755 index 0000000..378b4c8 --- /dev/null +++ b/src/ZigUP/Source/delay.h @@ -0,0 +1,2 @@ +void _delay_us(uint16 microSecs); +void _delay_ms(uint16 milliSecs); diff --git a/src/ZigUP/Source/dht22.c b/src/ZigUP/Source/dht22.c new file mode 100755 index 0000000..fcd1358 --- /dev/null +++ b/src/ZigUP/Source/dht22.c @@ -0,0 +1,107 @@ +#include +#include "onboard.h" +#include "bitmasks.h" +#include "delay.h" +#include "dht22.h" +#include "uart.h" +#include "global.h" + +int DHT22_Measure(void) +{ + uint8 last_state = 0xFF; + uint8 i; + uint8 j = 0; + uint8 counter = 0; + uint8 checksum = 0; + uint8 dht22_data[5]; + + /* + uint8 dht22_debug[100]; + uint8 debugcnt; + for(debugcnt = 0; debugcnt < 100; debugcnt++) dht22_debug[debugcnt] = 0; + debugcnt = 0; + */ + + P0DIR |= (1<<7); // output + P0_7 = 1; + _delay_ms(250); + P0_7 = 0; + _delay_ms(1); + P0DIR &= ~(1<<7); // input + + for(i = 0; i < 85; i++) + { + counter = 0; + while(P0_7 == last_state) + { + counter++; + _delay_us(1); + + if(counter > 60) break; // Exit if not responsive + } + last_state = P0_7; + + if(counter > 60) break; // Double check for stray sensor + + // Ignore the first 3 transitions (the 80us x 2 start condition plus the first ready-to-send-bit state), and discard ready-to-send-bit counts + if((i >= 4) && ((i % 2) != 0)) + { + dht22_data[j / 8] <<= 1; + // dht22_debug[debugcnt++] = counter; + if(counter > 20) // detect "1" bit time + { + dht22_data[j / 8] |= 1; + } + j++; + } + } + + char buffer[100]; + /* + sprintf(buffer, "j: %u", j); + UART_String(buffer); + + for(i = 0; i < 5; i++) + { + sprintf(buffer, "DHT22: (%u) %u\n", i, dht22_data[i]); + UART_String(buffer); +} + + for(debugcnt = 0; debugcnt < 100; debugcnt++) + { + sprintf(buffer, "DHT22 Debug: (%u) %u\n", debugcnt, dht22_debug[debugcnt]); + UART_String(buffer); +} + */ + + // If we have 5 bytes (40 bits), wrap-up and end + if(j >= 40) + { + // The first 2 bytes are humidity values, the next 2 are temperature, the final byte is the checksum + checksum = dht22_data[0] + dht22_data[1] + dht22_data[2] + dht22_data[3]; + checksum &= 0xFF; + if(dht22_data[4] == checksum) + { + float humidity = (dht22_data[0] * 256 + dht22_data[1]) / 10.0; + float temperature = ((dht22_data[2] & b01111111)* 256 + dht22_data[3]) / 10.0; + if (dht22_data[2] & b10000000) temperature = -temperature; // negative temperatures when MSB is set + + EXT_Temperature = temperature; + EXT_Humidity = humidity; + + sprintf(buffer, "DHT22: %.1f °C / %.1f %%\n", temperature, humidity); + UART_String(buffer); + return (1); + } + else + { + UART_String("DHT22: CRC-Fail"); + return (0); + } + } + else + { + UART_String("DHT22: Timeout"); + return (0); + } +} diff --git a/src/ZigUP/Source/dht22.h b/src/ZigUP/Source/dht22.h new file mode 100755 index 0000000..c2323c1 --- /dev/null +++ b/src/ZigUP/Source/dht22.h @@ -0,0 +1 @@ +int DHT22_Measure(void); diff --git a/src/ZigUP/Source/ds18b20.c b/src/ZigUP/Source/ds18b20.c new file mode 100755 index 0000000..52e8c17 --- /dev/null +++ b/src/ZigUP/Source/ds18b20.c @@ -0,0 +1,103 @@ +#include +#include "onboard.h" +#include "ZComDef.h" +#include "bitmasks.h" +#include "delay.h" +#include "ds18b20.h" +#include "uart.h" +#include "global.h" + +// Sends one bit to bus +void ds18b20_send(uint8 bit) +{ + P0DIR |= (1<<7); // output + P0_7 = 0; + _delay_us(5); + if (bit==1) P0_7 = 1; + _delay_us(80); + P0_7 = 1; +} + +// Reads one bit from bus +uint8 ds18b20_read(void) +{ + P0DIR |= (1<<7); // output + P0_7 = 0; + _delay_us(2); + P0_7 = 1; + _delay_us(15); + P0DIR &= ~(1<<7); // input + return P0_7; +} + +// Sends one byte to bus +void ds18b20_send_byte(int8 data) +{ + uint8 i,x; + for(i=0;i<8;i++) + { + x = data>>i; + x &= 0x01; + ds18b20_send(x); + } + _delay_us(100); +} + +// Reads one byte from bus +uint8 ds18b20_read_byte(void) +{ + uint8 i; + uint8 data = 0; + for (i=0;i<8;i++) + { + if(ds18b20_read()) data|=0x01< +#include "onboard.h" +#include "ZComDef.h" +#include "bitmasks.h" +#include "delay.h" +#include "ds18b20.h" +#include "uart.h" +#include "global.h" +#include "ws2812.h" +#include "led.h" +#include "interrupts.h" +#include "zcl_zigup.h" +#include "utils.h" + +#pragma vector=P0INT_VECTOR +__interrupt void IRQ_S0(void) +{ + if (P0IFG & (1<<6)) // Interrupt flag for P0.6 (S0)? + { + // debounce + _delay_ms(5); + if (!P0_6) // still pressed? + { + /* + WS2812_SendLED(255, 0, 0); + _delay_ms(500); + WS2812_SendLED(127, 0, 0); + _delay_ms(500); + WS2812_SendLED(63, 0, 0); + _delay_ms(500); + + WS2812_SendLED(0, 255, 0); + _delay_ms(500); + WS2812_SendLED(0, 127, 0); + _delay_ms(500); + WS2812_SendLED(0, 63, 0); + _delay_ms(500); + + WS2812_SendLED(0, 0, 255); + _delay_ms(500); + WS2812_SendLED(0, 0, 127); + _delay_ms(500); + WS2812_SendLED(0, 0, 63); + _delay_ms(500); + */ + S0++; + UART_String("[INT] S0!"); + char buffer[100]; + sprintf(buffer, "S0-Counts: %lu", S0); + UART_String(buffer); + + + // FactoryReset(); + + + + LED(!STATE_LED); + + } + + // Clear interrupt flags + P0IFG &= ~(1<<6); // Clear Interrupt flag for P0.6 (S0) + IRCON &= ~(1<<5); // Clear Interrupt flag for Port 0 + } +} + +#pragma vector=P1INT_VECTOR +__interrupt void IRQ_KEY(void) +{ + if (P1IFG & (1<<3)) // Interrupt flag for P1.3 (KEY)? + { + // debounce + _delay_ms(20); + if (!P1_3) // still pressed? + { + uint8 counter = 0; + while (!P1_3 && counter++ < 100) + { + _delay_ms(10); + counter++; + } + if (counter > 50) UART_String("lang"); + else UART_String("kurz"); + + + + WS2812_SendLED(22, 55, 11); + Relais(!STATE_LIGHT); + UART_String("[INT] KEY!"); + char buffer[100]; + sprintf(buffer, "Light-Status: %u", STATE_LIGHT); + UART_String(buffer); + + Measure(); + zclZigUP_Reporting(); + } + + // Clear interrupt flags + P1IFG &= ~(1<<3); // Clear Interrupt flag for P1.3 (KEY) + IRCON2 &= ~(1<<3); // Clear Interrupt flag for Port 1 + } +} + +#pragma vector=P2INT_VECTOR +__interrupt void IRQ_DIGIN(void) +{ + if (P2IFG & (1<<0)) // Interrupt flag for P2.0 (Dig-In)? + { + // debounce + _delay_ms(20); + if (!P2_0) // still pressed? + { + UART_String("[INT] Dig-In!"); + DIG_IN = P2_0; + } + + // Clear interrupt flags + P2IFG &= ~(1<<0); // Clear Interrupt flag for P2.0 (Dig-In) + IRCON2 &= ~(1<<0); // Clear Interrupt flag for Port 2 + } +} diff --git a/src/ZigUP/Source/interrupts.h b/src/ZigUP/Source/interrupts.h new file mode 100755 index 0000000..a398d30 --- /dev/null +++ b/src/ZigUP/Source/interrupts.h @@ -0,0 +1,3 @@ +__interrupt void IRQ_S0(void); +__interrupt void IRQ_KEY(void); +__interrupt void IRQ_DIGIN(void); diff --git a/src/ZigUP/Source/led.c b/src/ZigUP/Source/led.c new file mode 100755 index 0000000..c4b13d1 --- /dev/null +++ b/src/ZigUP/Source/led.c @@ -0,0 +1,20 @@ +#include "onboard.h" +#include "global.h" +#include "led.h" + +void LED(uint8 state) +{ + P1SEL &= ~BV(6); // LED = GPIO + + if (state) // Switch LED on + { + P1_6 = 1; // ON + } + else // Switch LED off + { + P1_6 = 0; // OFF + } + + STATE_LED = state; +} + diff --git a/src/ZigUP/Source/led.h b/src/ZigUP/Source/led.h new file mode 100755 index 0000000..51a8b77 --- /dev/null +++ b/src/ZigUP/Source/led.h @@ -0,0 +1 @@ +void LED(uint8 state); diff --git a/src/ZigUP/Source/random.c b/src/ZigUP/Source/random.c new file mode 100755 index 0000000..42b4404 --- /dev/null +++ b/src/ZigUP/Source/random.c @@ -0,0 +1,9 @@ +#include "onboard.h" +#include "bitmasks.h" +#include "random.h" + +uint8 GetRandomNumber(void) +{ + ADCCON1 = b00110111; // Clock the LFSR once (13x unrolling) + return RNDL; +} diff --git a/src/ZigUP/Source/random.h b/src/ZigUP/Source/random.h new file mode 100755 index 0000000..b8f07c7 --- /dev/null +++ b/src/ZigUP/Source/random.h @@ -0,0 +1 @@ +uint8 GetRandomNumber(void); diff --git a/src/ZigUP/Source/uart.c b/src/ZigUP/Source/uart.c new file mode 100755 index 0000000..e54d960 --- /dev/null +++ b/src/ZigUP/Source/uart.c @@ -0,0 +1,29 @@ +#include "ZComDef.h" +#include "onboard.h" +#include "uart.h" + +void UART_Init(void) +{ + U0CSR |= (1<<7); // Mode = UART, Receiver disabled + // U0UCR defaults ok (8,N,1) + + U0GCR = 11; // 115200 Baud + U0BAUD = 216; // 115200 Baud +} + +void UART_Transmit(char data) +{ + + U0DBUF = data; + while (U0CSR & (1<<0)); // wait until byte has been sent +} + +void UART_String(const char *s) +{ + while (*s) + { + UART_Transmit(*s++); + } + UART_Transmit('\r'); + UART_Transmit('\n'); +} diff --git a/src/ZigUP/Source/uart.h b/src/ZigUP/Source/uart.h new file mode 100755 index 0000000..d28d65e --- /dev/null +++ b/src/ZigUP/Source/uart.h @@ -0,0 +1,3 @@ +void UART_Init(void); +void UART_Transmit(char data); +void UART_String(const char *s); diff --git a/src/ZigUP/Source/utils.c b/src/ZigUP/Source/utils.c new file mode 100755 index 0000000..0ecd3f4 --- /dev/null +++ b/src/ZigUP/Source/utils.c @@ -0,0 +1,38 @@ +#include "hal_flash.h" +#include "onboard.h" +#include "delay.h" +#include "uart.h" +#include "global.h" +#include "utils.h" + +void FactoryReset(void) +{ + UART_String("Performing factory reset..."); + for (int i = HAL_NV_PAGE_BEG; i <= (HAL_NV_PAGE_BEG + HAL_NV_PAGE_CNT); i++) + { + HalFlashErase(i); + } + + UART_String("Performing system reset..."); + SystemReset(); +} + +void Relais(uint8 state) +{ + if (state) // Switch light on + { + P1_1 = 1; // activate ON-solenoid + P1_2 = 0; // deactivate OFF-solenoid + _delay_ms(250); + P1_1 = 0; // deactivate ON-solenoid + } + else // Switch light off + { + P1_1 = 0; // deactivate ON-solenoid + P1_2 = 1; // activate OFF-solenoid + _delay_ms(250); + P1_2 = 0; // deactivate OFF-solenoid + } + + STATE_LIGHT = state; +} diff --git a/src/ZigUP/Source/utils.h b/src/ZigUP/Source/utils.h new file mode 100755 index 0000000..8323e49 --- /dev/null +++ b/src/ZigUP/Source/utils.h @@ -0,0 +1,2 @@ +void FactoryReset(void); +void Relais(uint8 state); diff --git a/src/ZigUP/Source/ws2812.c b/src/ZigUP/Source/ws2812.c new file mode 100755 index 0000000..810b776 --- /dev/null +++ b/src/ZigUP/Source/ws2812.c @@ -0,0 +1,117 @@ +#include "ZComDef.h" +#include "onboard.h" +#include "ws2812.h" + +uint8 WS2812_buffer[WS2812_buffersize]; +uint8 WS2812_bit=0; +uint16 WS2812_byte=0; + +void WS2812_StoreBit(uint8 bit) +{ + // store bit (only the 1 bits) + if (bit) WS2812_buffer[WS2812_byte] |= 1 << WS2812_bit; + WS2812_bit++; + + // 8 bits per byte... + if (WS2812_bit > 7) + { + WS2812_bit = 0; + WS2812_byte++; + } +} + +void WS2812_SendLED(uint8 red, uint8 green, uint8 blue) +{ + P1SEL |= BV(6); // LED = Peripheral + + WS2812_bit = 0; + WS2812_byte = 0; + + // delete buffer + for (uint16 i=0; i> (i-1)) & 1) + { + WS2812_StoreBit(1); + WS2812_StoreBit(1); + WS2812_StoreBit(0); + } + else + { + WS2812_StoreBit(1); + WS2812_StoreBit(0); + WS2812_StoreBit(0); + } + } + for (i=8; i; i--) + { + if ((red >> (i-1)) & 1) + { + WS2812_StoreBit(1); + WS2812_StoreBit(1); + WS2812_StoreBit(0); + } + else + { + WS2812_StoreBit(1); + WS2812_StoreBit(0); + WS2812_StoreBit(0); + } + } + for (i=8; i; i--) + { + if ((blue >> (i-1)) & 1) + { + WS2812_StoreBit(1); + WS2812_StoreBit(1); + WS2812_StoreBit(0); + } + else + { + WS2812_StoreBit(1); + WS2812_StoreBit(0); + WS2812_StoreBit(0); + } + } + + // SPI method - a little bit jittery, but LED-Stripes seem to be okay with it + for (uint16 j=0; j> 8; + DMACONFIG[1] = (uint16)(&WS2812_buffer) & 0xff; + + // DMA destination address + DMACONFIG[2] = 0x70; + DMACONFIG[3] = 0xf9; // Address of U1DBUF + + // DMA length + DMACONFIG[4] = WS2812_buffersize; + DMACONFIG[5] = WS2812_buffersize; + + // DMA block transfer, no trigger + DMACONFIG[6] = b00100000; + + // DMA address increment for source only, high priority + DMACONFIG[7] = b01000010; + + DMA0CFGH = (uint16)(&DMACONFIG) >> 8; // DMA Channel-0 Configuration Address High Byte + DMA0CFGL = (uint16)(&DMACONFIG) & 0xff; // DMA Channel-0 Configuration Address Low Byte + + DMAARM = b00000001; // DMA Arm channel 0 + DMAREQ = b00000001; // DMA transfer request channel 0 + */ +} diff --git a/src/ZigUP/Source/ws2812.h b/src/ZigUP/Source/ws2812.h new file mode 100755 index 0000000..7385e08 --- /dev/null +++ b/src/ZigUP/Source/ws2812.h @@ -0,0 +1,5 @@ +// buffersize = num_leds * 24 bits * 3 bits per bit / 8 bit +#define WS2812_buffersize 9 + +void WS2812_StoreBit(uint8 bit); +void WS2812_SendLED(uint8 red, uint8 green, uint8 blue); diff --git a/src/ZigUP/Source/zcl_zigup.c b/src/ZigUP/Source/zcl_zigup.c index 201b0dc..f7d5524 100755 --- a/src/ZigUP/Source/zcl_zigup.c +++ b/src/ZigUP/Source/zcl_zigup.c @@ -1,72 +1,27 @@ -/********************************************************************* -* INCLUDES -*/ -#include "zcl_zigup.h" - -#include "ZComDef.h" -#include "OSAL.h" -#include "AF.h" -#include "ZDApp.h" -#include "ZDObject.h" -#include "MT_SYS.h" - -#include "nwk_util.h" - -#include "zcl.h" -#include "zcl_ha.h" -#include "zcl_ms.h" -#include "zcl_ezmode.h" -#include "zcl_diagnostic.h" - -#include "onboard.h" - -/* HAL */ -#include "hal_lcd.h" -#include "hal_led.h" -#include "hal_key.h" - -#include "NLMEDE.h" -#include "ZDSecMgr.h" -#include "hal_flash.h" - #include #include #include +#include "zcl_zigup.h" +#include "zcl.h" +#include "zcl_ha.h" +#include "zcl_diagnostic.h" +#include "onboard.h" +#include "ZDSecMgr.h" +#include "bitmasks.h" +#include "delay.h" +#include "ds18b20.h" +#include "uart.h" +#include "global.h" +#include "adc.h" +#include "random.h" +#include "ws2812.h" +#include "interrupts.h" +#include "led.h" +#include "dht22.h" +#include "utils.h" -/********************************************************************* -* MACROS -*/ - -/********************************************************************* -* CONSTANTS -*/ #define ZIGUP_REPORTING_INTERVAL 5000 -/********************************************************************* -* TYPEDEFS -*/ -/********************************************************************* -* GLOBAL VARIABLES -*/ -byte zclZigUP_TaskID; -uint16 zclZigUPSeqNum=0; - -volatile uint32 S0=0; -volatile uint8 STATE_LIGHT=0; -volatile uint8 STATE_LED=0; - -#define WS2812_buffersize 9 -uint8 WS2812_buffer[WS2812_buffersize]; -uint8 WS2812_bit=0; -uint16 WS2812_byte=0; - -/********************************************************************* -* GLOBAL FUNCTIONS -*/ - -/********************************************************************* -* LOCAL VARIABLES -*/ afAddrType_t zclZigUP_DstAddr; uint16 bindingInClusters[] = @@ -86,420 +41,19 @@ static endPointDesc_t ZigUP_TestEp = devStates_t zclZigUP_NwkState = DEV_INIT; -float ADC_Voltage = -1000;; -float CPU_Temperature = -1000; -float EXT_Temperature = -1000; -float EXT_Humidity = -1000; -uint16 DIG_IN = 0; - -/********************************************************************* -* LOCAL FUNCTIONS -*/ - -#pragma inline=forced -void _delay_ns_400(void) -{ - /* 13 NOPs == 400nsecs */ - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - asm("nop"); asm("nop"); asm("nop"); -} - -#pragma inline=forced -void _delay_ns_800(void) -{ - /* 26 NOPs == 800nsecs */ - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - asm("nop"); -} - -#pragma inline=forced -void _delay_us(uint16 microSecs) -{ - while(microSecs--) - { - asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop"); - } -} - -void _delay_ms(uint16 milliSecs) -{ - while(milliSecs--) - { - _delay_us(1000); - } -} - -void FactoryReset(void) -{ - UART0_String("Performing factory reset..."); - for (int i = HAL_NV_PAGE_BEG; i <= (HAL_NV_PAGE_BEG + HAL_NV_PAGE_CNT); i++) - { - HalFlashErase(i); - } - - UART0_String("Performing system reset..."); - SystemReset(); -} - -uint16 ADC_Read(void) -{ - int16 result = 0; - ADCCON3 = b00110000; // internal reference, decimation 512, channel 0, start conversation - while (!(ADCCON1 & (1<<7))); // wait for conversation to finish - result = (uint16)ADCL; - result |= (uint16)(ADCH << 8); - if (result < 0) result = 0; - result >>= 2; - return result; -} - -uint16 ADC_Read_Avg(void) -{ - uint32 result = 0; - for (uint8 i=0; i<32; i++) result += ADC_Read(); - return (uint16)(result / 32); -} - -float ADC_GetVoltage(void) -{ - return ADC_Read_Avg() * 0.003949905; -} - -uint16 ADC_Temperature(void) -{ - int16 result = 0; - ADCCON3 = b00111110; // internal reference, decimation 512, temperature, start conversation - while (!(ADCCON1 & (1<<7))); // wait for conversation to finish - result = (uint16)ADCL; - result |= (uint16)(ADCH << 8); - if (result < 0) result = 0; - result >>= 2; - return result; -} - -uint16 ADC_Temperature_Avg(void) -{ - TR0 = 1; // connect the temperature sensor to the SOC_ADC - ATEST = 1; // Enables the temperature sensor - - uint32 result = 0; - for (uint8 i=0; i<32; i++) result += ADC_Temperature(); - - ATEST = 0; // Disables the temperature sensor - TR0 = 0; // disconnect the temperature sensor from the SOC_ADC - - return (uint16)(result / 32); -} - -float ADC_GetTemperature(void) -{ - return ADC_Temperature_Avg() * 0.0556 - 303.89; -} - -void UART0_Init(void) -{ - U0CSR |= (1<<7); // Mode = UART, Receiver disabled - // U0UCR defaults ok (8,N,1) - - U0GCR = 11; // 115200 Baud - U0BAUD = 216; // 115200 Baud -} - -void UART0_Transmit(char data) -{ - - U0DBUF = data; - while (U0CSR & (1<<0)); // wait until byte has been sent -} - -void UART0_String(const char *s) -{ - while (*s) - { - UART0_Transmit(*s++); - } - UART0_Transmit('\r'); - UART0_Transmit('\n'); -} - -void Relais(uint8 state) -{ - if (state) // Switch light on - { - P1_1 = 1; // ON - P1_2 = 0; // OFF - _delay_ms(250); - P1_1 = 0; // ON - } - else // Switch light off - { - P1_1 = 0; // ON - P1_2 = 1; // OFF - _delay_ms(250); - P1_2 = 0; // OFF - } - - STATE_LIGHT = state; -} - -void LED(uint8 state) -{ - P1SEL &= ~BV(6); // LED = GPIO - - if (state) // Switch LED on - { - P1_6 = 1; // ON - } - else // Switch LED off - { - P1_6 = 0; // OFF - } - - STATE_LED = state; -} - -void WS2812_StoreBit(uint8 bit) -{ - // store bit (only the 1 bits) - if (bit) WS2812_buffer[WS2812_byte] |= 1 << WS2812_bit; - WS2812_bit++; - - // 8 bits per byte... - if (WS2812_bit > 7) - { - WS2812_bit = 0; - WS2812_byte++; - } -} - -void WS2812_SendLED(uint8 red, uint8 green, uint8 blue) -{ - P1SEL |= BV(6); // LED = Peripheral - - WS2812_bit = 0; - WS2812_byte = 0; - - // delete buffer - for (uint16 i=0; i> (i-1)) & 1) - { - WS2812_StoreBit(1); - WS2812_StoreBit(1); - WS2812_StoreBit(0); - } - else - { - WS2812_StoreBit(1); - WS2812_StoreBit(0); - WS2812_StoreBit(0); - } - } - for (i=8; i; i--) - { - if ((red >> (i-1)) & 1) - { - WS2812_StoreBit(1); - WS2812_StoreBit(1); - WS2812_StoreBit(0); - } - else - { - WS2812_StoreBit(1); - WS2812_StoreBit(0); - WS2812_StoreBit(0); - } - } - for (i=8; i; i--) - { - if ((blue >> (i-1)) & 1) - { - WS2812_StoreBit(1); - WS2812_StoreBit(1); - WS2812_StoreBit(0); - } - else - { - WS2812_StoreBit(1); - WS2812_StoreBit(0); - WS2812_StoreBit(0); - } - } - - // SPI method - a little bit jittery, but LED-Stripes seem to be okay with it - for (uint16 j=0; j> 8; - DMACONFIG[1] = (uint16)(&WS2812_buffer) & 0xff; - - // DMA destination address - DMACONFIG[2] = 0x70; - DMACONFIG[3] = 0xf9; // Address of U1DBUF - - // DMA length - DMACONFIG[4] = WS2812_buffersize; - DMACONFIG[5] = WS2812_buffersize; - - // DMA block transfer, no trigger - DMACONFIG[6] = b00100000; - - // DMA address increment for source only, high priority - DMACONFIG[7] = b01000010; - - DMA0CFGH = (uint16)(&DMACONFIG) >> 8; // DMA Channel-0 Configuration Address High Byte - DMA0CFGL = (uint16)(&DMACONFIG) & 0xff; // DMA Channel-0 Configuration Address Low Byte - - DMAARM = b00000001; // DMA Arm channel 0 - DMAREQ = b00000001; // DMA transfer request channel 0 - */ -} - -uint8 GetRandomNumber(void) -{ - ADCCON1 = b00110111; // Clock the LFSR once (13x unrolling) - return RNDL; -} - -#pragma vector=P0INT_VECTOR -__interrupt void IRQ_S0(void) -{ - if (P0IFG & (1<<6)) // Interrupt flag for P0.6 (S0)? - { - // debounce - _delay_ms(5); - if (!P0_6) // still pressed? - { - /* - WS2812_SendLED(255, 0, 0); - _delay_ms(500); - WS2812_SendLED(127, 0, 0); - _delay_ms(500); - WS2812_SendLED(63, 0, 0); - _delay_ms(500); - - WS2812_SendLED(0, 255, 0); - _delay_ms(500); - WS2812_SendLED(0, 127, 0); - _delay_ms(500); - WS2812_SendLED(0, 63, 0); - _delay_ms(500); - - WS2812_SendLED(0, 0, 255); - _delay_ms(500); - WS2812_SendLED(0, 0, 127); - _delay_ms(500); - WS2812_SendLED(0, 0, 63); - _delay_ms(500); - */ - S0++; - UART0_String("[INT] S0!"); - char buffer[100]; - sprintf(buffer, "S0-Counts: %lu", S0); - UART0_String(buffer); - - - // FactoryReset(); - - - - LED(!STATE_LED); - - } - - // Clear interrupt flags - P0IFG &= ~(1<<6); // Clear Interrupt flag for P0.6 (S0) - IRCON &= ~(1<<5); // Clear Interrupt flag for Port 0 - } -} - -#pragma vector=P1INT_VECTOR -__interrupt void IRQ_KEY(void) -{ - if (P1IFG & (1<<3)) // Interrupt flag for P1.3 (KEY)? - { - // debounce - _delay_ms(20); - if (!P1_3) // still pressed? - { - uint8 counter = 0; - while (!P1_3 && counter++ < 100) - { - _delay_ms(10); - counter++; - } - if (counter > 50) UART0_String("lang"); - else UART0_String("kurz"); - - - - WS2812_SendLED(22, 55, 11); - Relais(!STATE_LIGHT); - UART0_String("[INT] KEY!"); - char buffer[100]; - sprintf(buffer, "Light-Status: %u", STATE_LIGHT); - UART0_String(buffer); - - Measure(); - zclZigUP_Reporting(); - } - - // Clear interrupt flags - P1IFG &= ~(1<<3); // Clear Interrupt flag for P1.3 (KEY) - IRCON2 &= ~(1<<3); // Clear Interrupt flag for Port 1 - } -} - -#pragma vector=P2INT_VECTOR -__interrupt void IRQ_DIGIN(void) -{ - if (P2IFG & (1<<0)) // Interrupt flag for P2.0 (Dig-In)? - { - // debounce - _delay_ms(20); - if (!P2_0) // still pressed? - { - UART0_String("[INT] Dig-In!"); - DIG_IN = P2_0; - } - - // Clear interrupt flags - P2IFG &= ~(1<<0); // Clear Interrupt flag for P2.0 (Dig-In) - IRCON2 &= ~(1<<0); // Clear Interrupt flag for Port 2 - } -} - void Measure(void) { ADC_Voltage = ADC_GetVoltage(); CPU_Temperature = ADC_GetTemperature(); -// if (!DHT22_Measure()) -// { + if (!DHT22_Measure()) + { EXT_Humidity = -1000; if (!ds18b20_get_temp()) { EXT_Temperature = -1000; } -// } + } } void zclZigUP_Reporting(void) @@ -552,205 +106,7 @@ void zclZigUP_Reporting(void) osal_mem_free( pReportCmd ); } -int DHT22_Measure(void) -{ - uint8 last_state = 0xFF; - uint8 i; - uint8 j = 0; - uint8 counter = 0; - uint8 checksum = 0; - uint8 dht22_data[5]; - - /* - uint8 dht22_debug[100]; - uint8 debugcnt; - for(debugcnt = 0; debugcnt < 100; debugcnt++) dht22_debug[debugcnt] = 0; - debugcnt = 0; - */ - - P0DIR |= (1<<7); // output - P0_7 = 1; - _delay_ms(250); - P0_7 = 0; - _delay_ms(1); - P0DIR &= ~(1<<7); // input - - for(i = 0; i < 85; i++) - { - counter = 0; - while(P0_7 == last_state) - { - counter++; - _delay_us(1); - - if(counter > 60) break; // Exit if not responsive - } - last_state = P0_7; - - if(counter > 60) break; // Double check for stray sensor - - // Ignore the first 3 transitions (the 80us x 2 start condition plus the first ready-to-send-bit state), and discard ready-to-send-bit counts - if((i >= 4) && ((i % 2) != 0)) - { - dht22_data[j / 8] <<= 1; - // dht22_debug[debugcnt++] = counter; - if(counter > 20) // detect "1" bit time - { - dht22_data[j / 8] |= 1; - } - j++; - } - } - - char buffer[100]; - /* - sprintf(buffer, "j: %u", j); - UART0_String(buffer); - - for(i = 0; i < 5; i++) - { - sprintf(buffer, "DHT22: (%u) %u\n", i, dht22_data[i]); - UART0_String(buffer); -} - - for(debugcnt = 0; debugcnt < 100; debugcnt++) - { - sprintf(buffer, "DHT22 Debug: (%u) %u\n", debugcnt, dht22_debug[debugcnt]); - UART0_String(buffer); -} - */ - - // If we have 5 bytes (40 bits), wrap-up and end - if(j >= 40) - { - // The first 2 bytes are humidity values, the next 2 are temperature, the final byte is the checksum - checksum = dht22_data[0] + dht22_data[1] + dht22_data[2] + dht22_data[3]; - checksum &= 0xFF; - if(dht22_data[4] == checksum) - { - float humidity = (dht22_data[0] * 256 + dht22_data[1]) / 10.0; - float temperature = ((dht22_data[2] & b01111111)* 256 + dht22_data[3]) / 10.0; - if (dht22_data[2] & b10000000) temperature = -temperature; // negative temperatures when MSB is set - - EXT_Temperature = temperature; - EXT_Humidity = humidity; - - sprintf(buffer, "DHT22: %.1f °C / %.1f %%\n", temperature, humidity); - UART0_String(buffer); - return (1); - } - else - { - UART0_String("DHT22: CRC-Fail"); - return (0); - } - } - else - { - UART0_String("DHT22: Timeout"); - return (0); - } -} -int DS1820_Measure(void) -{ - return (0); -} - -// Sends one bit to bus -void ds18b20_send(uint8 bit) -{ - P0DIR |= (1<<7); // output - P0_7 = 0; - _delay_us(5); - if (bit==1) P0_7 = 1; - _delay_us(80); - P0_7 = 1; -} - -// Reads one bit from bus -uint8 ds18b20_read(void) -{ - P0DIR |= (1<<7); // output - P0_7 = 0; - _delay_us(2); - P0_7 = 1; - _delay_us(15); - P0DIR &= ~(1<<7); // input - return P0_7; -} - -// Sends one byte to bus -void ds18b20_send_byte(int8 data) -{ - uint8 i,x; - for(i=0;i<8;i++) - { - x = data>>i; - x &= 0x01; - ds18b20_send(x); - } - _delay_us(100); -} - -// Reads one byte from bus -uint8 ds18b20_read_byte(void) -{ - uint8 i; - uint8 data = 0; - for (i=0;i<8;i++) - { - if(ds18b20_read()) data|=0x01< 0 ) { osal_start_timerEx( zclZigUP_TaskID, ZIGUP_IDENTIFY_TIMEOUT_EVT, 1000 ); - HalLedBlink ( HAL_LED_4, 0xFF, HAL_LED_DEFAULT_DUTY_CYCLE, HAL_LED_DEFAULT_FLASH_TIME ); +// HalLedBlink ( HAL_LED_4, 0xFF, HAL_LED_DEFAULT_DUTY_CYCLE, HAL_LED_DEFAULT_FLASH_TIME ); } else { diff --git a/src/ZigUP/Source/zcl_zigup.h b/src/ZigUP/Source/zcl_zigup.h index 0c34ef5..958b7f0 100755 --- a/src/ZigUP/Source/zcl_zigup.h +++ b/src/ZigUP/Source/zcl_zigup.h @@ -6,15 +6,10 @@ extern "C" { #endif -/********************************************************************* - * INCLUDES - */ #include "zcl.h" #include "zcl_general.h" -/********************************************************************* - * CONSTANTS - */ + #define ZIGUP_ENDPOINT 8 #define LIGHT_OFF 0x00 @@ -32,274 +27,6 @@ extern "C" #define ATTRID_ADC_VOLT 41365 #define ATTRID_DIG_INPUT 41366 -// Bitmasks -#define b00000000 0x00 -#define b00000001 0x01 -#define b00000010 0x02 -#define b00000011 0x03 -#define b00000100 0x04 -#define b00000101 0x05 -#define b00000110 0x06 -#define b00000111 0x07 -#define b00001000 0x08 -#define b00001001 0x09 -#define b00001010 0x0a -#define b00001011 0x0b -#define b00001100 0x0c -#define b00001101 0x0d -#define b00001110 0x0e -#define b00001111 0x0f -#define b00010000 0x10 -#define b00010001 0x11 -#define b00010010 0x12 -#define b00010011 0x13 -#define b00010100 0x14 -#define b00010101 0x15 -#define b00010110 0x16 -#define b00010111 0x17 -#define b00011000 0x18 -#define b00011001 0x19 -#define b00011010 0x1a -#define b00011011 0x1b -#define b00011100 0x1c -#define b00011101 0x1d -#define b00011110 0x1e -#define b00011111 0x1f -#define b00100000 0x20 -#define b00100001 0x21 -#define b00100010 0x22 -#define b00100011 0x23 -#define b00100100 0x24 -#define b00100101 0x25 -#define b00100110 0x26 -#define b00100111 0x27 -#define b00101000 0x28 -#define b00101001 0x29 -#define b00101010 0x2a -#define b00101011 0x2b -#define b00101100 0x2c -#define b00101101 0x2d -#define b00101110 0x2e -#define b00101111 0x2f -#define b00110000 0x30 -#define b00110001 0x31 -#define b00110010 0x32 -#define b00110011 0x33 -#define b00110100 0x34 -#define b00110101 0x35 -#define b00110110 0x36 -#define b00110111 0x37 -#define b00111000 0x38 -#define b00111001 0x39 -#define b00111010 0x3a -#define b00111011 0x3b -#define b00111100 0x3c -#define b00111101 0x3d -#define b00111110 0x3e -#define b00111111 0x3f -#define b01000000 0x40 -#define b01000001 0x41 -#define b01000010 0x42 -#define b01000011 0x43 -#define b01000100 0x44 -#define b01000101 0x45 -#define b01000110 0x46 -#define b01000111 0x47 -#define b01001000 0x48 -#define b01001001 0x49 -#define b01001010 0x4a -#define b01001011 0x4b -#define b01001100 0x4c -#define b01001101 0x4d -#define b01001110 0x4e -#define b01001111 0x4f -#define b01010000 0x50 -#define b01010001 0x51 -#define b01010010 0x52 -#define b01010011 0x53 -#define b01010100 0x54 -#define b01010101 0x55 -#define b01010110 0x56 -#define b01010111 0x57 -#define b01011000 0x58 -#define b01011001 0x59 -#define b01011010 0x5a -#define b01011011 0x5b -#define b01011100 0x5c -#define b01011101 0x5d -#define b01011110 0x5e -#define b01011111 0x5f -#define b01100000 0x60 -#define b01100001 0x61 -#define b01100010 0x62 -#define b01100011 0x63 -#define b01100100 0x64 -#define b01100101 0x65 -#define b01100110 0x66 -#define b01100111 0x67 -#define b01101000 0x68 -#define b01101001 0x69 -#define b01101010 0x6a -#define b01101011 0x6b -#define b01101100 0x6c -#define b01101101 0x6d -#define b01101110 0x6e -#define b01101111 0x6f -#define b01110000 0x70 -#define b01110001 0x71 -#define b01110010 0x72 -#define b01110011 0x73 -#define b01110100 0x74 -#define b01110101 0x75 -#define b01110110 0x76 -#define b01110111 0x77 -#define b01111000 0x78 -#define b01111001 0x79 -#define b01111010 0x7a -#define b01111011 0x7b -#define b01111100 0x7c -#define b01111101 0x7d -#define b01111110 0x7e -#define b01111111 0x7f -#define b10000000 0x80 -#define b10000001 0x81 -#define b10000010 0x82 -#define b10000011 0x83 -#define b10000100 0x84 -#define b10000101 0x85 -#define b10000110 0x86 -#define b10000111 0x87 -#define b10001000 0x88 -#define b10001001 0x89 -#define b10001010 0x8a -#define b10001011 0x8b -#define b10001100 0x8c -#define b10001101 0x8d -#define b10001110 0x8e -#define b10001111 0x8f -#define b10010000 0x90 -#define b10010001 0x91 -#define b10010010 0x92 -#define b10010011 0x93 -#define b10010100 0x94 -#define b10010101 0x95 -#define b10010110 0x96 -#define b10010111 0x97 -#define b10011000 0x98 -#define b10011001 0x99 -#define b10011010 0x9a -#define b10011011 0x9b -#define b10011100 0x9c -#define b10011101 0x9d -#define b10011110 0x9e -#define b10011111 0x9f -#define b10100000 0xa0 -#define b10100001 0xa1 -#define b10100010 0xa2 -#define b10100011 0xa3 -#define b10100100 0xa4 -#define b10100101 0xa5 -#define b10100110 0xa6 -#define b10100111 0xa7 -#define b10101000 0xa8 -#define b10101001 0xa9 -#define b10101010 0xaa -#define b10101011 0xab -#define b10101100 0xac -#define b10101101 0xad -#define b10101110 0xae -#define b10101111 0xaf -#define b10110000 0xb0 -#define b10110001 0xb1 -#define b10110010 0xb2 -#define b10110011 0xb3 -#define b10110100 0xb4 -#define b10110101 0xb5 -#define b10110110 0xb6 -#define b10110111 0xb7 -#define b10111000 0xb8 -#define b10111001 0xb9 -#define b10111010 0xba -#define b10111011 0xbb -#define b10111100 0xbc -#define b10111101 0xbd -#define b10111110 0xbe -#define b10111111 0xbf -#define b11000000 0xc0 -#define b11000001 0xc1 -#define b11000010 0xc2 -#define b11000011 0xc3 -#define b11000100 0xc4 -#define b11000101 0xc5 -#define b11000110 0xc6 -#define b11000111 0xc7 -#define b11001000 0xc8 -#define b11001001 0xc9 -#define b11001010 0xca -#define b11001011 0xcb -#define b11001100 0xcc -#define b11001101 0xcd -#define b11001110 0xce -#define b11001111 0xcf -#define b11010000 0xd0 -#define b11010001 0xd1 -#define b11010010 0xd2 -#define b11010011 0xd3 -#define b11010100 0xd4 -#define b11010101 0xd5 -#define b11010110 0xd6 -#define b11010111 0xd7 -#define b11011000 0xd8 -#define b11011001 0xd9 -#define b11011010 0xda -#define b11011011 0xdb -#define b11011100 0xdc -#define b11011101 0xdd -#define b11011110 0xde -#define b11011111 0xdf -#define b11100000 0xe0 -#define b11100001 0xe1 -#define b11100010 0xe2 -#define b11100011 0xe3 -#define b11100100 0xe4 -#define b11100101 0xe5 -#define b11100110 0xe6 -#define b11100111 0xe7 -#define b11101000 0xe8 -#define b11101001 0xe9 -#define b11101010 0xea -#define b11101011 0xeb -#define b11101100 0xec -#define b11101101 0xed -#define b11101110 0xee -#define b11101111 0xef -#define b11110000 0xf0 -#define b11110001 0xf1 -#define b11110010 0xf2 -#define b11110011 0xf3 -#define b11110100 0xf4 -#define b11110101 0xf5 -#define b11110110 0xf6 -#define b11110111 0xf7 -#define b11111000 0xf8 -#define b11111001 0xf9 -#define b11111010 0xfa -#define b11111011 0xfb -#define b11111100 0xfc -#define b11111101 0xfd -#define b11111110 0xfe -#define b11111111 0xff - -/********************************************************************* - * MACROS - */ -/********************************************************************* - * TYPEDEFS - */ - -/********************************************************************* - * VARIABLES - */ extern SimpleDescriptionFormat_t zclZigUP_SimpleDesc[]; extern CONST zclCommandRec_t zclZigUP_Cmds[]; @@ -317,43 +44,13 @@ extern uint8 zclZigUP_IdentifyCommissionState; // OnOff attributes extern uint8 zclZigUP_OnOff; -/********************************************************************* - * FUNCTIONS - */ -void _delay_ns_400(void); -void _delay_ns_800(void); -void _delay_us(uint16 microSecs); -void _delay_ms(uint16 milliSecs); void FactoryReset(void); -uint16 ADC_Read(void); -uint16 ADC_Read_Avg(void); -float ADC_GetVoltage(void); -uint16 ADC_Temperature(void); -uint16 ADC_Temperature_Avg(void); -float ADC_GetTemperature(void); -void UART0_Init(void); -void UART0_Transmit(char data); -void UART0_String(const char *s); + void Relais(uint8 state); void LED(uint8 state); -void WS2812_StoreBit(uint8 bit); -void WS2812_SendLED(uint8 red, uint8 green, uint8 blue); -uint8 GetRandomNumber(void); -__interrupt void IRQ_S0(void); -__interrupt void IRQ_KEY(void); -__interrupt void IRQ_DIGIN(void); void zclZigUP_Reporting(void); void Measure(void); -int DHT22_Measure(void); -int DS1820_Measure(void); - -void ds18b20_send(uint8 bit); -uint8 ds18b20_read(void); -void ds18b20_send_byte(int8 data); -uint8 ds18b20_read_byte(void); -uint8 ds18b20_RST_PULSE(void); -uint8 ds18b20_get_temp(void); static void zclZigUP_BasicResetCB( void ); static void zclZigUP_IdentifyCB( zclIdentify_t *pCmd ); @@ -387,9 +84,6 @@ extern void zclZigUP_Init( byte task_id ); extern UINT16 zclZigUP_event_loop( byte task_id, UINT16 events ); -/********************************************************************* -*********************************************************************/ - #ifdef __cplusplus } #endif diff --git a/src/ZigUP/Source/zcl_zigup_data.c b/src/ZigUP/Source/zcl_zigup_data.c index 957e8e1..d3df6c2 100755 --- a/src/ZigUP/Source/zcl_zigup_data.c +++ b/src/ZigUP/Source/zcl_zigup_data.c @@ -1,6 +1,3 @@ -/********************************************************************* - * INCLUDES - */ #include "ZComDef.h" #include "OSAL.h" #include "AF.h" @@ -23,28 +20,12 @@ #include "zcl_zigup.h" -/********************************************************************* - * CONSTANTS - */ - #define ZIGUP_DEVICE_VERSION 0 #define ZIGUP_FLAGS 0 #define ZIGUP_HWVERSION 1 #define ZIGUP_ZCLVERSION 1 -/********************************************************************* - * TYPEDEFS - */ - -/********************************************************************* - * MACROS - */ - -/********************************************************************* - * GLOBAL VARIABLES - */ - // Basic Cluster const uint8 zclZigUP_HWRevision = ZIGUP_HWVERSION; const uint8 zclZigUP_ZCLVersion = ZIGUP_ZCLVERSION; @@ -241,16 +222,3 @@ SimpleDescriptionFormat_t zclZigUP_SimpleDesc[1] = { (cId_t *)zclZigUP_OutClusterList // byte *pAppInClusterList; } }; - -/********************************************************************* - * GLOBAL FUNCTIONS - */ - -/********************************************************************* - * LOCAL FUNCTIONS - */ - -/**************************************************************************** -****************************************************************************/ - -