Hi, All!
Собсвенно недостающие части от предыдущего исходника. По просьбам.
=== bit.h === #ifndef __BIT_H #define __BIT_H /* * Filename : bit.h * Compiler : IAR AT90S C-Compiler V1.40E * Version : 1.2 * Created : 26.08.2000 * Modified : 24.12.2001 * * Description : * Bit macroses for accessing I/O ports and I/O registers. * on, off, signal, cpl - for operations with indication of * active logical level; useful for i/o ports * SETBIT, CLEARBIT, TESTBIT, CPLBIT - for operations with * registers (active level - HIGH) * * Copyright (c) Askold Volkov snipped-for-privacy@inp.nsk.su>
- All rights reserved. * Modified by Eugene Soloshenko snipped-for-privacy@mail.ru * * Usage example: * #define LED PORTB,0,L // LED connected to PORTB-bit0; active level LOW * #define HOOK_ON PINB,2,H // Hook sw. connected to PortB-bit2. Active HI. * * while (signal(HOOK_ON)) { // wait while hook is off * }; * on(LED); // light the LED * off(LED); * cpl(LED); */
#define _setL(port,bit_n) ( port&=~(1<<bit_n) ) #define _setH(port,bit_n) ( port|=(1<<bit_n) ) #define _set(port,bit_n,val) _set##val(port,bit_n) #define on(x) _set(x) #define SETBIT _setH
#define _clrL(port,bit_n) ( port|=(1<<bit_n) ) #define _clrH(port,bit_n) ( port&=~(1<<bit_n) ) #define _clr(port,bit_n,val) _clr##val(port,bit_n) #define off(x) _clr(x) #define CLEARBIT _clrH
#define _bitL(port,bit_n) ( !(port&(1<<bit_n)) ) #define _bitH(port,bit_n) ( port&(1<<bit_n) ) #define _bit(port,bit_n,val) _bit##val(port,bit_n) #define signal(x) _bit(x) #define TESTBIT _bitH
#define _cpl(port,bit_n,val) ( port^=(1<<bit_n) ) #define cpl(x) _cpl(x) #define CPLBIT(port,bit_n) ( port^=(1<<bit_n) )
#endif
=== bit.h ===
=== macros.h === /* Useful macros */ #define uchar unsigned char #define uint unsigned int
#define u8 unsigned char #define s8 signed char #define u16 unsigned int #define s16 signed int #define u32 unsigned long int #define s32 signed long int
/* Byte access */ #define WLO 0 // for word, MSB first #define WHI 1
#define UL0 0 // for unsigned long #define UL1 1 #define UL2 2 #define UL3 3
#define BYTE(x,b) *(((uchar*)(&x))+b)
/* Access to external memory */ #define XMEM(adr) ( *(volatile uchar *)(adr) )
=== macros.h ===
=== hardw.h === #ifndef __HARDW_H #define __HARDW_H
/* * Hardware section for AVR AT90s2313 */
/* Watchdog timer */ //#define WDT_ON // swithc on WDT at release #define _WDT_REG 0x0C // 00001100b = 256K @ 1Mhz; WDT period = 240 mS
/* * Pins definition */ #define BUSY PORTD,4,H // pin.8 #define CS PIND,5,H // pin.9 - Chip Select #define RW PIND,6,H // pin.11 - Read/Write #define STB PINB,2,H // pin.14 - data Strobe #define SMPL_TEST PORTB,3,H // pin.15 - Test Sample frequency
#define COMP ACSR,ACO,H // internal comparator output (no external pin)
#define DATA_H_OUT PORTD // out data high nibble (Port0-Port3) #define DATA_L_OUT PORTB // out data low nibble (Port4-Port7)
#define DATA_H_IN PIND // in data high nibble (Port0-Port3) #define DATA_L_IN PINB // in data low nibble (Port4-Port7)
/* * Direction. Pull-ups * Pins that not used are switched to output low level */ /* Port B */ #define _DIRB_IN 0x08 // data bus as input // 00001000b ( 0-input, 1-output ) // 0 AIN0 - in // 1 AIN1 - in // 2 STB - in // 3 SMPL_TEST - out // 4 DB0 - in // 5 DB1 - in // 6 DB2 - in // 7 DB3 - in
#define _DIRB_OUT 0xF8 // data bus as output // 11111000b ( 0-input, 1-output ) // 0 AIN0 - in // 1 AIN1 - in // 2 STB - in // 3 SMPL_TEST - out // 4 DB0 - out // 5 DB1 - out // 6 DB2 - out // 7 DB3 - out
#define _PORT_B 0x0 // 1-switch on pull-up (for input)
/* Port D */ #define _DIRD_IN 0x10 // data bus as input // 00010000b ( 0-input, 1-output ) // 0 DB4 - in // 1 DB5 - in // 2 DB6 - in // 3 DB7 - in // 4 BUSY - out // 5 CS - in // 6 R/W - in // 7 x - doesn't exist
#define _DIRD_OUT 0x1F // data bus as input // 00011111b ( 0-input, 1-output ) // 0 DB4 - out // 1 DB5 - out // 2 DB6 - out // 3 DB7 - out // 4 BUSY - out // 5 CS - in // 6 R/W - in // 7 x - doesn't exist
#define _DIRD_Z 0x0 // data bus as input // 00000000b ( 0-input, 1-output ) // 0 DB4 - in // 1 DB5 - in // 2 DB6 - in // 3 DB7 - in // 4 BUSY - in // 5 CS - in // 6 R/W - in // 7 x - doesn't exist
#define _PORT_D 0x0 // 1-switch on pull-up (for input)
/* Macros */ #define init_port() {\ DDRB = _DIRB_IN;\ PORTB = _PORT_B;\ DDRD = _DIRD_Z;\ PORTD = _PORT_D;\ }
#endif
=== hardw.h ===
wbr, eugene // solosh '\x40' mail.ru