极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 16608|回复: 1

求助··蓝牙手柄上ATmega8L-8PU最简单下载方法

[复制链接]
发表于 2012-5-6 10:52:51 | 显示全部楼层 |阅读模式
如题
最近在研究手机用蓝牙手柄
资料查了几天几夜  但ATmega8L-8PU上下载程序难倒了  没有单片机经验  拿HEX文件找人烧可行否?
该图属网上收集不知道作者 冒犯了

请帮助下  如果你能烧录  我购买也成
QQ 389731523
烧录代码有了

代码:
#include <avr/io.h>
#include <avr/iom8.h>
#include <avr/macros.h>

void Delay_mS(unsigned int Time) {
    unsigned char n;

    while(Time > 0) {
        for(n = 1; n < 187; n++) {
            asm("nop");
        }
        Time--;
    }
}

void port_init(void) {
        PORTB = 0xff;
        DDRB  = 0x00;
        PORTC = 0xff; //m103 output only
        DDRC  = 0x00;
        PORTD = 0xff;
        DDRD  = 0x00;
}

void uart0_init(void) {
        UCSRB = 0x00; //disable while setting baud rate
        UCSRA = 0x02;
        UCSRC = BIT(URSEL) | 0x06;
        UBRRL = 0x67; //set baud rate low (9600)
        UBRRH = 0x00; //set baud rate high
        UCSRB = 0x18;
}

void init_devices(void) {
        //stop errant interrupts until set up
        CLI(); //disable all interrupts
        port_init();
        uart0_init();
        
        MCUCR = 0x00;
        GICR  = 0x00;
        TIMSK = 0x00; //timer interrupt sources
        SEI(); //re-enable interrupts
        //all peripherals are now initialized
}

void uart0_putChar(unsigned char ch) {
    while(!(UCSRA & (1 << UDRE)))
                ;
    UDR = ch;
}

int main (void) {
        unsigned short preKey = 0xFFFF;
        unsigned short tmp = 0xFFFF;
        
        init_devices();
        
        tmp = ((PINB | 0xFFC1) >> 1) & (((0xFFE0 | PINC) << 5) | 0b1111110000011111);
        preKey = tmp;
        
        while(1) {
                tmp = ((PINB | 0xFFC1) >> 1) & (((0xFFE0 | PINC) << 5) | 0b1111110000011111);
               
                if(preKey != tmp) {
               
                        Delay_mS(30);
                        
                        if(preKey != tmp) {
                                preKey = tmp;
                                uart0_putChar(0xf0);
                                uart0_putChar(~(preKey >> 8));
                                uart0_putChar(~preKey);
                                uart0_putChar(0x0f);
                        }
                }
        }
        return 0;
}

要不有ATmega8L-8PU的烧两个来我直接买吧{:soso_e127:}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2012-5-7 12:20:14 | 显示全部楼层
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-5-2 20:31 , Processed in 0.056187 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表