divers
This commit is contained in:
parent
a8e9e14f12
commit
cd7f3a694f
4 changed files with 77 additions and 37 deletions
2
lcd.c
2
lcd.c
|
|
@ -252,6 +252,6 @@ void lcd_write(uint8_t value)
|
||||||
send(value, LCD_DATA);
|
send(value, LCD_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_backlight(uint8_t value){
|
void lcd_backlight(uint8_t value){
|
||||||
_BackliteOn = value?1:0;
|
_BackliteOn = value?1:0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
103
main.c
103
main.c
|
|
@ -12,9 +12,80 @@
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
#include "spi.h"
|
||||||
|
#include "rf24.h"
|
||||||
|
|
||||||
|
int main (void);
|
||||||
|
void setup (void);
|
||||||
|
void loop (void);
|
||||||
|
void lcdprint( char* ptr);
|
||||||
|
|
||||||
|
|
||||||
void lcdprint( char* ptr){
|
int main(void)
|
||||||
|
{
|
||||||
|
setup();
|
||||||
|
while (1)
|
||||||
|
loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(void)
|
||||||
|
{
|
||||||
|
lcd_init(20,4);
|
||||||
|
lcd_backlight(1);
|
||||||
|
lcd_clear();
|
||||||
|
lcd_home();
|
||||||
|
lcdprint("Pyro RF ! ");
|
||||||
|
|
||||||
|
spi_init_master();
|
||||||
|
|
||||||
|
rf24_init();
|
||||||
|
|
||||||
|
char st = rf24_read_reg(CONFIG);
|
||||||
|
debughex(&st,1);
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega32A__)
|
||||||
|
// setup Timer1
|
||||||
|
TCCR1A = 0;
|
||||||
|
TCNT1=0;
|
||||||
|
OCR1A = 2000;
|
||||||
|
TIMSK = _BV(OCIE1A);
|
||||||
|
TCCR1B = _BV(WGM12)|_BV(CS11);
|
||||||
|
#elif defined(__AVR_ATmega2560__)
|
||||||
|
// setup Timer1
|
||||||
|
TCCR1A = 0;
|
||||||
|
TCNT1=0;
|
||||||
|
OCR1A = 10000;
|
||||||
|
TIMSK1 = _BV(OCIE1A);
|
||||||
|
TCCR1B = _BV(WGM12)|_BV(CS11);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sei();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
volatile int i=0,j=0;
|
||||||
|
volatile int u=0;
|
||||||
|
|
||||||
|
void loop(void)
|
||||||
|
{ if(!u){
|
||||||
|
u=20;
|
||||||
|
char buf[15];
|
||||||
|
lcd_setCursor(0,1);
|
||||||
|
snprintf(buf,15,"%d %d ",i,j++);
|
||||||
|
lcdprint(buf);
|
||||||
|
}
|
||||||
|
set_sleep_mode(SLEEP_MODE_IDLE);
|
||||||
|
sleep_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ISR(TIMER1_COMPA_vect){
|
||||||
|
i+=5;
|
||||||
|
if(u)u--;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcdprint( char* ptr)
|
||||||
|
{
|
||||||
while (*ptr) lcd_write(*ptr++);
|
while (*ptr) lcd_write(*ptr++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,34 +100,4 @@ void debughex (char* ptr,uint8_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
bitSet(DDRB,7);
|
|
||||||
lcd_init(20,4);
|
|
||||||
lcd_clear();
|
|
||||||
_delay_ms(1000);
|
|
||||||
|
|
||||||
lcd_home();
|
|
||||||
lcd_display();
|
|
||||||
lcdprint("PyRO RF !");
|
|
||||||
lcd_setCursor(0,3);
|
|
||||||
lcdprint("Arnaud HOUDELETTE");
|
|
||||||
_delay_ms(3000);
|
|
||||||
lcd_backlight(1);
|
|
||||||
lcd_display();
|
|
||||||
_delay_ms(3000);
|
|
||||||
//lcd_backlight(0);
|
|
||||||
lcd_display();
|
|
||||||
while (1){
|
|
||||||
lcd_setCursor(0,3);
|
|
||||||
lcdprint("Arnaud HOUDELETTE");
|
|
||||||
_delay_ms(1000);
|
|
||||||
lcd_setCursor(0,3);
|
|
||||||
lcdprint("Emmanuel LANGLOIS");
|
|
||||||
_delay_ms(1000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
5
rf24.c
5
rf24.c
|
|
@ -4,6 +4,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
uint8_t rf24_buffer[33];
|
uint8_t rf24_buffer[33];
|
||||||
|
|
||||||
|
|
@ -13,8 +14,8 @@ uint8_t rf24_CONFIG = _BV(MASK_TX_DS)|_BV(MASK_MAX_RT);
|
||||||
uint8_t rf24_status;
|
uint8_t rf24_status;
|
||||||
uint8_t rf24_fifo;
|
uint8_t rf24_fifo;
|
||||||
|
|
||||||
uint8_t rf24_addr_P0[]={ 0xE7, 0xE7, 0xE7, 0xE7, 0xE7 };
|
uint8_t rf24_addr_sl[]={ 0xE7, 0xE7, 0xE7, 0xE7, 0xE7 };
|
||||||
uint8_t rf24_addr_P1[]={ 0xC2, 0xC2, 0xC2, 0xC2, 0xC1 };
|
uint8_t rf24_addr_mstr[]={ 0xC2, 0xC2, 0xC2, 0xC2, 0xC1 };
|
||||||
|
|
||||||
|
|
||||||
void inline rf24_ceHi(){
|
void inline rf24_ceHi(){
|
||||||
|
|
|
||||||
4
spi.c
4
spi.c
|
|
@ -2,18 +2,16 @@
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void spi_init_master() {
|
void spi_init_master() {
|
||||||
|
|
||||||
SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0);
|
|
||||||
|
|
||||||
SPI_PORT |= _BV(SCK_PIN);
|
SPI_PORT |= _BV(SCK_PIN);
|
||||||
SPI_DDR |= _BV(MOSI_PIN) | _BV(SCK_PIN) | _BV(SS_PIN);
|
SPI_DDR |= _BV(MOSI_PIN) | _BV(SCK_PIN) | _BV(SS_PIN);
|
||||||
|
SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR1)| _BV(SPR0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t spi_transfer(uint8_t b) {
|
uint8_t spi_transfer(uint8_t b) {
|
||||||
|
|
||||||
SPDR = b;
|
SPDR = b;
|
||||||
while (!(SPSR & _BV(SPIF)));
|
while (!(SPSR & _BV(SPIF)));
|
||||||
return SPDR;
|
return SPDR;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue