реклама на сайте
подробности

 
 
> Проблема с типами?
Jenya7
сообщение Mar 30 2012, 13:12
Сообщение #1


Профессионал
*****

Группа: Участник
Сообщений: 1 778
Регистрация: 29-03-12
Пользователь №: 71 075



Привет всем!
Тула IAR C/C++ Compiler for AVR 5.51.0.
Столкнулся с проблемой.
В ir.c:
CODE
union UWORD
{
int VALUE;
struct
{
unsigned char bit0:1;
unsigned char bit1:1;
unsigned char bit2:1;
unsigned char bit3:1;
unsigned char bit4:1;
unsigned char bit5:1;
unsigned char bit6:1;
unsigned char bit7:1;
unsigned char bit8:1;
unsigned char bit9:1;
unsigned char bit10:1;
unsigned char bit11:1;
unsigned char bit12:1;
unsigned char bit13:1;
unsigned char bit14:1;
unsigned char bit15:1;
}bits;
};

union UWORD ir_bits = {0};

char get_rc5_bit(void)
{
delay_us(1650);
return IR_IN;
}

int GetRc5Data(void)
{
delay_us(3000);
tb = IR_IN; //ToggBit
//get address
ir_bits.bits.bit10 = get_rc5_bit();
ir_bits.bits.bit9 = get_rc5_bit();
ir_bits.bits.bit8 = get_rc5_bit();
ir_bits.bits.bit7 = get_rc5_bit();
ir_bits.bits.bit6 = get_rc5_bit();
//get command
ir_bits.bits.bit5 = get_rc5_bit();
ir_bits.bits.bit4 = get_rc5_bit();
ir_bits.bits.bit3 = get_rc5_bit();
ir_bits.bits.bit2 = get_rc5_bit();
ir_bits.bits.bit1 = get_rc5_bit();
ir_bits.bits.bit0 = get_rc5_bit();
return ir_bits.VALUE;
}


В main.c:
Код
volatile char ir_com;
volatile char ir_add;
volatile int ir_code;

if(intflag.ir)   //IR remote pressed
    {
      ir_code = GetRc5Data();
      ir_com = ir_code & 0x003F;     //bit0-bit5
      SendInt("ir command: ",ir_com);
      ir_add = (ir_code & 0x07C0) >> 6;  //bit6-bit10
      //ir_add = (ir_code >> 6) & 0x1F; - actually the same
      SendInt("ir address: ",ir_add);
      intflag.ir = 0;
    }


Проблема в том что в ir_com я получаю корректный результат, а в ir_add я получаю ерунду( т.е 0).
К тому же при компиляции вылетает:Warning[w6]: Type conflict for external/entry "GetRc5Data", in module main against external/entry in module ir; function return types are different; different
basic types
Буду признателен если кто нибудь прояснит где я напортачил.

Сообщение отредактировал IgorKossak - Mar 30 2012, 13:20
Причина редактирования: [codebox] для длинного кода!!!
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 3rd August 2025 - 09:16
Рейтинг@Mail.ru


Страница сгенерированна за 0.01474 секунд с 7
ELECTRONIX ©2004-2016