[an error occurred while processing this directive]
|
#include #include "define.h" #ifdef Old_ADC_routine // Measurements void main(void) // Ports and Perefireal Units configuration // Read Data // Test printing }// ------------------ end "for()" ----------------- return; // Error handler function // USART service (non interrupt)
E-mail:
info@telesys.ru
#include
#include "func.c"
#include "I2C_mega8.c"
#include "IrDa.c"
#include "measurement.c"
#else
#include "ADC_func.c"
#endif// End of ADC routine define
#ifdef Debugging
#include "DebugFunc.c"
#endif
{
/*
// unsigned short volatile __io *ptrSP = &SP;
unsigned short *ptrSP;// = &SP;
// unsigned int volatile *ptrSP;// = &SP;
ptrSP = SP;
ptrSP++;
*ptrSP = 0xAA;
*/
UnitCFG();
#ifdef Debugging
DebugFunc();
#endif
//########################################################################
/* Two-wire Serial Interface (TWI).
non interrupt.
Byte[0] - Status Word(Byte[0].7 = Read/nWrite (bit.7), Byte[0].6-0 = Number of chars (bit.6-0));
Byte[1] - Address;
Byte[2 - ...] - Data (for Transmit if Byte[0].7 = "1" or Reseive if Byte[0].7 = "0")
-----------------------------------------------------------------------------------------------------
Current project use for service of RTC DS1307 and story data.
*/
char I2C_mega8(char *BufferI2C){
char i, j;
// Checking Mode
if(*BufferI2C & 0x80){// "READ MODE" SELECTED ------------------------------------------
// Write beginning Address
TWCR = (1<
TWDR = SLA_W;
TWCR = (1<
++BufferI2C; TWDR = *BufferI2C; // Address Write
TWCR = (1<
TWCR = (1<
TWCR = (1<
TWDR = SLA_R;
TWCR = (1<
j = 0;
for(i = (*BufferI2C & 0x3F); i; i--){// ------------------ begin "for()" -----------------
TWCR = (1<
// while(!( UCSRA & (1<
// End of Test printing
TWCR = (1<
TWCR = (1<
else{// "WRITE MODE" SELECTED ------------------------------------------
// Write beginning Address
TWCR = (1<
TWDR = SLA_W;
TWCR = (1<
for(i = *BufferI2C; i; i--){
++BufferI2C; TWDR = *BufferI2C; // Address and Data Write
TWCR = (1<
}
TWCR = (1<
return 1;
}// End of "char I2C_mega8(char SW_I2C, ){"
//#############################################################################
void UnitCFG(void){
// Ports configuration
// DDRB = ; PORTB = ; // PB.0,1-REZERV; PB.2-"DamageLED"; Isolation: PB.3-IN,PB.4,5-OUT;
// DDRC = ; PORTC = ; // PC.0-3-ADC; PC.4-TWI_SDA, PC.5-TWI_SCL;
// DDRD = ; PORTD = ; // PD.0,1-RS485; PD.2-"ZeroDetector"; PD.3-IrDA_IN; PD.4-IrDA_OUT; PD.5-Starter; PD.6-Heater; PD.7-Free
// Config of ADC; (Normal conversions, single ended = 112 mkSec)
ADCSR = (1 << ADEN)|(1 << ADIE)|(6); // ADC - turn "ON"; Interrupt - enable; Prescaler = 110b what eq. 8 MHz/64 = 125kHz
// Config of TCNT1 (in Mode 4 - CTC)
TCCR1A = 0;
// TCCR1B = (1<
// Config of USART;
UBRRH = 0; // Set baud rate
UBRRL = 8;
UCSRB = (1<
TWBR = 8; // Bit Rate setting
TWSR = 1; // Prescaler setting
}// End of "void UnitCFG(void)"{ -------------------------------------------------------------------
void ERROR(char i){
while(!(UCSRA & (1<
void USART_Transmit(unsigned char *ptrData){
unsigned char i;
while(!(UCSRA & (1<
for(i = 0; *ptrData; ++i){
while(!(UCSRA & (1<
}
while(!( UCSRA & (1<
Ответы
Перейти к списку ответов
|||
Конференция
|||
Архив
|||
Главная страница
|||
Содержание