⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logger.lst

📁 ENC28J60 System HTTP
💻 LST
📖 第 1 页 / 共 4 页
字号:
   1               		.file	"logger.c"
   2               	__SREG__ = 0x3f
   3               	__SP_H__ = 0x3e
   4               	__SP_L__ = 0x3d
   5               	__CCP__  = 0x34
   6               	__tmp_reg__ = 0
   7               	__zero_reg__ = 1
   8               		.global __do_copy_data
   9               		.global __do_clear_bss
  11               		.text
  12               	.Ltext0:
 106               	.global	logger_output_temp
 108               	logger_output_temp:
   1:apps/logger.c **** /*
   2:apps/logger.c **** ,-----------------------------------------------------------------------------------------.
   3:apps/logger.c **** | apps/logger
   4:apps/logger.c **** |-----------------------------------------------------------------------------------------
   5:apps/logger.c **** | this file implements a temperature logger
   6:apps/logger.c **** | - store current day in eeprom (240 bytes)
   7:apps/logger.c **** | - (add later: backup day at 0 o'clock to dataflash)
   8:apps/logger.c **** |
   9:apps/logger.c **** | Author   : {{removed according to contest rules}}
  10:apps/logger.c **** |            -> circuitcellar.com avr design contest 2006
  11:apps/logger.c **** |            -> Entry #AT2616
  12:apps/logger.c **** |-----------------------------------------------------------------------------------------
  13:apps/logger.c **** | License:
  14:apps/logger.c **** | This program is free software; you can redistribute it and/or modify it under
  15:apps/logger.c **** | the terms of the GNU General Public License as published by the Free Software
  16:apps/logger.c **** | Foundation; either version 2 of the License, or (at your option) any later
  17:apps/logger.c **** | version.
  18:apps/logger.c **** | This program is distributed in the hope that it will be useful, but
  19:apps/logger.c **** |
  20:apps/logger.c **** | WITHOUT ANY WARRANTY;
  21:apps/logger.c **** |
  22:apps/logger.c **** | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  23:apps/logger.c **** | PURPOSE. See the GNU General Public License for more details.
  24:apps/logger.c **** |
  25:apps/logger.c **** | You should have received a copy of the GNU General Public License along with
  26:apps/logger.c **** | this program; if not, write to the Free Software Foundation, Inc., 51
  27:apps/logger.c **** | Franklin St, Fifth Floor, Boston, MA 02110, USA
  28:apps/logger.c **** |
  29:apps/logger.c **** | http://www.gnu.de/gpl-ger.html
  30:apps/logger.c **** `-----------------------------------------------------------------------------------------*/
  31:apps/logger.c **** 
  32:apps/logger.c **** #include "logger.h"
  33:apps/logger.c **** 
  34:apps/logger.c **** //ACTIVATE DEBUG by editing this file:
  35:apps/logger.c **** #include "debug.h"
  36:apps/logger.c **** 
  37:apps/logger.c **** //store current day in eeprom
  38:apps/logger.c **** unsigned char logger_temp_today[240] EEMEM;
  39:apps/logger.c **** 
  40:apps/logger.c **** //some status vars
  41:apps/logger.c **** unsigned char logger_count;
  42:apps/logger.c **** unsigned int  logger_lastsave;
  43:apps/logger.c **** unsigned char logger_data;
  44:apps/logger.c **** 
  45:apps/logger.c **** //log every 7*8 = 56 seconds:
  46:apps/logger.c **** #define LOGGER_COUNTER_INIT 7
  47:apps/logger.c **** 
  48:apps/logger.c **** //initialise logger
  49:apps/logger.c **** void logger_init(){
  50:apps/logger.c **** 	logger_count    = 1;
  51:apps/logger.c **** 	logger_lastsave = 0;
  52:apps/logger.c **** 	logger_data = (32<<1); //0°C
  53:apps/logger.c **** 
  54:apps/logger.c **** 	//let lm75 grab first data, try it 2 times
  55:apps/logger.c **** 	//(2*8 calls!)
  56:apps/logger.c **** 	unsigned char data;
  57:apps/logger.c **** 	for(unsigned char c=0; c<16; c++)
  58:apps/logger.c **** 		if (lm75_nonblocking_temp_read(&data)==1)
  59:apps/logger.c **** 			break;
  60:apps/logger.c **** }
  61:apps/logger.c **** 
  62:apps/logger.c **** //call this function every second !
  63:apps/logger.c **** //it will grab the temperature every 56seconds
  64:apps/logger.c **** //and store the temperature in eeprom every 6 minutes:
  65:apps/logger.c **** void logger_do(){
  66:apps/logger.c **** 	unsigned char data;
  67:apps/logger.c **** 	
  68:apps/logger.c **** 	logger_count--;
  69:apps/logger.c **** 
  70:apps/logger.c **** 	//we need to log call the i2c statemachine:
  71:apps/logger.c **** 	if (!logger_count){
  72:apps/logger.c **** 		data = 0;
  73:apps/logger.c **** 		logger_count = LOGGER_COUNTER_INIT;
  74:apps/logger.c **** 
  75:apps/logger.c **** 		//if =1 -> there is a new temperature!
  76:apps/logger.c **** 		if (lm75_nonblocking_temp_read(&data)==1){
  77:apps/logger.c **** 			#if LOGGER_DEBUG
  78:apps/logger.c **** 			softuart_puts_progmem("LOG : ");
  79:apps/logger.c **** 			
  80:apps/logger.c **** 			signed char t = data-(32<<1);
  81:apps/logger.c **** 			if (t>=0){
  82:apps/logger.c **** 				softuart_put_uint8(t>>1);
  83:apps/logger.c **** 			}else{
  84:apps/logger.c **** 				softuart_putc('-');
  85:apps/logger.c **** 				softuart_put_uint8((-t)>>1);
  86:apps/logger.c **** 			}
  87:apps/logger.c **** 			softuart_putc('.');
  88:apps/logger.c **** 			if ((t&1) == 0)
  89:apps/logger.c **** 				softuart_putc('0');
  90:apps/logger.c **** 			else
  91:apps/logger.c **** 				softuart_putc('5');
  92:apps/logger.c **** 
  93:apps/logger.c **** 			softuart_puts_progmem(" C := ");
  94:apps/logger.c **** 			softuart_put_uint8(data);
  95:apps/logger.c **** 			softuart_putnewline();
  96:apps/logger.c **** 			#endif
  97:apps/logger.c **** 				
  98:apps/logger.c **** 			//calc eeprom pos:
  99:apps/logger.c **** 			unsigned int tnow = (clock[CLOCK_HOUR]*60+clock[CLOCK_MIN])/6;
 100:apps/logger.c **** 
 101:apps/logger.c **** 			//if this is the next day -> do backup!
 102:apps/logger.c **** 			if (tnow >= 23*60+59/6){
 103:apps/logger.c **** 				///BACKUP HERE to dataflash archive (add later!)
 104:apps/logger.c **** 			}else{
 105:apps/logger.c **** 				//save new data to eeprom:
 106:apps/logger.c **** 				if (tnow != logger_lastsave){
 107:apps/logger.c **** 					logger_lastsave = tnow;
 108:apps/logger.c **** 					eeprom_write_byte(&logger_temp_today[(tnow & 0xFF)], data); 
 109:apps/logger.c **** 				}
 110:apps/logger.c **** 				logger_count = 1;
 111:apps/logger.c **** 			}
 112:apps/logger.c **** 			logger_data = data;
 113:apps/logger.c **** 		}
 114:apps/logger.c **** 	}
 115:apps/logger.c **** }
 116:apps/logger.c **** 
 117:apps/logger.c **** //return LOGGER_NOW, LOGGER_MIN or LOGGER_MAX (temperature now, today min, today max)
 118:apps/logger.c **** void logger_output_temp(unsigned char *buffer, unsigned char type){
 109               	,.LM0-.LFBB1
 110               	.LM0:
 111               	.LFBB1:
 112 0000 1F93      		push r17
 113 0002 CF93      		push r28
 114 0004 DF93      		push r29
 115               	/* prologue: function */
 116               	/* frame size = 0 */
 117 0006 EC01      		movw r28,r24
 118 0008 E62F      		mov r30,r22
 119:apps/logger.c **** ((clock[CLOCK_HOUR]*60+clock[CLOCK_MIN])/6);
 120:apps/logger.c **** 	if (tnow > (23*60+59)/6)
 121:apps/logger.c **** 		tnow = (23*60+59)/6;
 122:apps/logger.c **** 
 123:apps/logger.c **** 	//only search from 0 o'clock to now !
 124:apps/logger.c **** 	for(unsigned char i=0; i<=tnow; i++){
 119               	,0,124,.LM1-.LFBB1
 120               	.LM1:
 121 000a 8091 0000 		lds r24,clock
 122 000e 2CE3      		ldi r18,lo8(60)
 123 0010 829F      		mul r24,r18
 124 0012 C001      		movw r24,r0
 125 0014 1124      		clr r1
 126 0016 2091 0000 		lds r18,clock+1
 127 001a 820F      		add r24,r18
 128 001c 911D      		adc r25,__zero_reg__
 129 001e 66E0      		ldi r22,lo8(6)
 130 0020 70E0      		ldi r23,hi8(6)
 131 0022 0E94 0000 		call __divmodhi4
 132 0026 603F      		cpi r22,lo8(-16)
 133 0028 00F0      		brlo .L2
 134 002a 6FEE      		ldi r22,lo8(-17)
 135               	.L2:
 136 002c 3FEF      		ldi r19,lo8(-1)
 137 002e 40E0      		ldi r20,lo8(0)
 138 0030 20E0      		ldi r18,lo8(0)
 139               	.L16:
 140               	.LBB8:
 141               	.LBB9:
 142               	.LBB10:
 144               	.Ltext1:
   1:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** /* Copyright (c) 2002, 2003, 2004, 2007 Marek Michalkiewicz
   2:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    Copyright (c) 2005, 2006 Bjoern Haase
   3:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    Copyright (c) 2008 Atmel Corporation
   4:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    Copyright (c) 2008 Wouter van Gulik
   5:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    All rights reserved.
   6:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 
   7:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    Redistribution and use in source and binary forms, with or without
   8:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    modification, are permitted provided that the following conditions are met:
   9:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 
  10:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    * Redistributions of source code must retain the above copyright
  11:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****      notice, this list of conditions and the following disclaimer.
  12:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    * Redistributions in binary form must reproduce the above copyright
  13:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****      notice, this list of conditions and the following disclaimer in
  14:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****      the documentation and/or other materials provided with the
  15:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****      distribution.
  16:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****    * Neither the name of the copyright holders nor the names of
  17:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****      contributors may be used to endorse or promote products derived
  18:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****      from this software without specific prior written permission.
  19:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 
  20:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  24:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h ****   POSSIBILITY OF SUCH DAMAGE. */
  31:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 
  32:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** /* $Id: eeprom.h,v 1.21.2.6 2008/08/19 22:10:39 arcanum Exp $ */
  33:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 
  34:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** #ifndef _AVR_EEPROM_H_
  35:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** #define _AVR_EEPROM_H_ 1
  36:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 
  37:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** #include <avr/io.h>
  38:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** #include <stddef.h>	/* size_t */
  39:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** #include <stdint.h>
  40:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 
  41:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** #ifdef __cplusplus
  42:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** extern "C" {
  43:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** #endif
  44:c:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h **** 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -