| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include <avr/io.h>
- #include <util/delay.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "nrf24l01.h"
- #include "nrf24l01_definitions.h"
- #include "bme280_interface.h"
- #include "bme280_defs.h"
-
- //#define LED_DDR DDRB //DDRA, DDRB...
- //#define LED_PORT PORTB //PORTA, PORTB...
- //#define LED_PORTPIN PB0 //PA0, PA1..., PB0, PB1..., ...
- //#define time_off 8
-
- /* SPI: */
- /* TODO: move to spi.h */
- #define SPI_DDR DDRB
- #define SPI_SCK_PIN PB5
- #define SPI_MOSI_PIN PB3
- #define SPI_MISO_PIN PB4
-
-
-
- char bool_case = 0;
- int timer = 0;
- int timer_max = 0;
-
-
- void Initialize_SPI(void);
-
- int main (void)
- {
- struct bme280_data sensorData;
- // uint8_t testRegisterContent = 0x0A;
- // uint8_t registerContent[5];
- // char registerContentString[30];
- // uint8_t lengthRead;
-
-
- /* Initialize the SPI */
- Initialize_SPI();
-
- /* Initialize the nrf24l01 */
- Initialize_NRF24L01();
- // The NRF24L01 is now in the mode Standby-I.
-
- /* Configure the transmission parameters (Enhanced ShockBurst)*/
- Configure_Transmission();
-
- /* Initialize the BME280 */
- Initialize_BME280();
-
-
-
- while(1)
- {
- BME280_Get_Measurement(&sensorData);
- NRF24L01_Send_Message((uint8_t*)&sensorData, sizeof(sensorData));
- _delay_ms(1000);
- }
- }
-
- void Initialize_SPI(void)
- {
- /* Set MOSI and SCK output, all others input */
- SPI_DDR = (1<<SPI_MOSI_PIN)|(1<<SPI_SCK_PIN);
- /* Enable SPI, Master, set clock rate fck/16 */
- SPCR = (1<<SPE)|(1<<MSTR);
- }
|