macros.h

#ifndef __MACROS_H
#define __MACROS_H 1

#if !defined(_AVR)
#error "This file should only be used with ICCV7 for AVR"
#endif

/* FOR ATMEL AVR and TINY AVR ONLY! */

#ifndef BIT
#define BIT(x) (1 << (x))
#endif

#if defined(_AVR) && !defined(flash)
#define flash const  /* IAR compatibility */
#endif

#ifndef C_task
#define C_task
#endif

#define _asm asm   /* old style */

#define WDR()  asm("wdr")
#define SLEEP() asm("sleep")
#define SEI() asm("sei")
#define CLI() asm("cli")
#define NOP() asm("nop")
#define _WDR()  asm("wdr")
#define _SEI() asm("sei")
#define _CLI() asm("cli")
#define _NOP() asm("nop")

#ifdef _AVR
/* Serial Port Macros
 * for 4 Mhz crystal!
 *
 * USE THE AppBuilder for UART initialization!!!
 */
#define BAUD9600 25
#define BAUD19K  12

/* NOT ALL (new) AVRs define these. Use the AppBuilder!!
 */
#define UART_TRANSMIT_ON() UCR |= 0x8
#define UART_TRANSMIT_OFF() UCR &= ~0x8
#define UART_RECEIVE_ON() UCR |= 0x10
#define UART_RECEIVE_OFF() UCR &= ~0x10

#define COMPRESS_DISABLE  NOCC_START()
#define COMPRESS_REENABLE  NOCC_END()

#define NOCC_START() asm(".nocc_start")
#define NOCC_END() asm(".nocc_end")

void _StackCheck(void);
void _StackOverflowed(char);

#endif

#endif

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include <iom16v.h> #include <macros.h> #define RS_0 PORTD &= ~(1 << PD3) #define RS_1 PORTD |= (1 << PD3) #define RW_0 PORTD &= ~(1 << PD4) #define RW_1 PORTD |= (1 << PD4) #define EN_0 PORTD &= ~(1 << PD6) #define EN_1 PORTD |= (1 << PD6) //微秒级延时程序晶振8MHZ void delay_us(int time) { do { time--; } while (time>1); } //毫秒级延时程序晶振8MHZ void delay_ms(unsigned int time) { while(time!=0) { delay_us(1000); time--; } } /*显示屏命令写入函数*/ void LCD_write_com(unsigned char com) { RS_0; RW_0; PORTB = com; EN_1; delay_us(20); EN_0; } /*显示屏命令写入函数*/ void LCD_write_data(unsigned char data) { RS_1; RW_0; PORTB = data; EN_1; delay_us(200); EN_0; } /*显示屏清空显示*/ void LCD_clear(void) { LCD_write_com(0x01); delay_ms(5); } /*显示屏字符串写入函数*/ void LCD_write_str(unsigned char x,unsigned char y,unsigned char *s) { if (y == 0) { LCD_write_com(0x80 + x); } else { LCD_write_com(0xC0 + x); } while (*s) { LCD_write_data( *s); s ++; } } /*显示屏单字符写入函数*/ void LCD_write_char(unsigned char x,unsigned char y,unsigned char data) { if (y == 0) { LCD_write_com(0x80 + x); } else { LCD_write_com(0xC0 + x); } LCD_write_data( data); } /*显示屏初始化函数*/ void LCD_init(void) { DDRB = 0xFF; /*I/O口方向设置*/ DDRD |= (1 << PD3) | (1 << PD4) | (1 << PD6); LCD_write_com(0x38); /*显示模式设置*/ delay_ms(5); LCD_write_com(0x38); delay_ms(5); LCD_write_com(0x38); delay_ms(5); LCD_write_com(0x38); LCD_write_com(0x08); /*显示关闭*/ LCD_write_com(0x01); /*显示清屏*/ LCD_write_com(0x06); /*显示光标移动设置*/ delay_ms(5); LCD_write_com(0x0C); /*显示开及光标设置*/ } void main(void) { unsigned char i; unsigned char *p; PORTA = 0xFF; /*打开上拉*/ DDRA = 0x00; /*方向输入*/ PORTB = 0xFF; /*电平设置*/ DDRB = 0xFF; /*方向输出*/ PORTC = 0x7F; DDRC = 0x80; PORTD = 0xFF; DDRD = 0x00; delay_ms(100); LCD_init(); while (1) { i = 1; p = "yixiangongren"; //LCD_clear(); LCD_write_str(1,0,"www.eehome.cn"); delay_ms(50); while (*p) { LCD_write_char(i,1,*p); i ++; p ++; //delay_ms(50); } delay_ms(500); } } 本文来自: 电子工程师之家http://www.eehome.cn
#ifndef TOMCRYPT_H_ #define TOMCRYPT_H_ #include <assert.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <ctype.h> #include <limits.h> /* use configuration data */ #include <tomcrypt_custom.h> #ifdef __cplusplus extern "C" { #endif /* version */ #define CRYPT 0x0116 #define SCRYPT "1.16" /* max size of either a cipher/hash block or symmetric key [largest of the two] */ #define MAXBLOCKSIZE 128 /* descriptor table size */ /* Dropbear change - this should be smaller, saves some size */ #define TAB_SIZE 4 /* error codes [will be expanded in future releases] */ enum { CRYPT_OK=0, /* Result OK */ CRYPT_ERROR, /* Generic Error */ CRYPT_NOP, /* Not a failure but no operation was performed */ CRYPT_INVALID_KEYSIZE, /* Invalid key size given */ CRYPT_INVALID_ROUNDS, /* Invalid number of rounds */ CRYPT_FAIL_TESTVECTOR, /* Algorithm failed test vectors */ CRYPT_BUFFER_OVERFLOW, /* Not enough space for output */ CRYPT_INVALID_PACKET, /* Invalid input packet given */ CRYPT_INVALID_PRNGSIZE, /* Invalid number of bits for a PRNG */ CRYPT_ERROR_READPRNG, /* Could not read enough from PRNG */ CRYPT_INVALID_CIPHER, /* Invalid cipher specified */ CRYPT_INVALID_HASH, /* Invalid hash specified */ CRYPT_INVALID_PRNG, /* Invalid PRNG specified */ CRYPT_MEM, /* Out of memory */ CRYPT_PK_TYPE_MISMATCH, /* Not equivalent types of PK keys */ CRYPT_PK_NOT_PRIVATE, /* Requires a private PK key */ CRYPT_INVALID_ARG, /* Generic invalid argument */ CRYPT_FILE_NOTFOUND, /* File Not Found */ CRYPT_PK_INVALID_TYPE, /* Invalid type of PK key */ CRYPT_PK_INVALID_SYSTEM,/* Invalid PK system specified */ CRYPT_PK_DUP, /* Duplicate key already in key ring */ CRYPT_PK_NOT_FOUND, /* Key not found in keyring */ CRYPT_PK_INVALID_SIZE, /* Invalid size input for PK parameters */ CRYPT_INVALID_PRIME_SIZE,/* Invalid size of prime requested */ CRYPT_PK_INVALID_PADDING /* Invalid padding on input */ }; #include <tomcrypt_cfg.h> #include <tomcrypt_macros.h> #include <tomcrypt_cipher.h> #include <tomcrypt_hash.h> #include <tomcrypt_mac.h> #include <tomcrypt_prng.h> #include <tomcrypt_pk.h> #include <tomcrypt_math.h> #include <tomcrypt_misc.h> #include <tomcrypt_argchk.h> #include <tomcrypt_pkcs.h> #ifdef __cplusplus } #endif #endif /* TOMCRYPT_H_ */ /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt.h,v $ */ /* $Revision: 1.20 $ */ /* $Date: 2006/11/26 01:45:14 $ */

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值