Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "nrf24l01.h"
  8. #include "nrf24l01_definitions.h"
  9. #include "bme280_interface.h"
  10. #include "bme280_defs.h"
  11. //#define LED_DDR DDRB //DDRA, DDRB...
  12. //#define LED_PORT PORTB //PORTA, PORTB...
  13. //#define LED_PORTPIN PB0 //PA0, PA1..., PB0, PB1..., ...
  14. //#define time_off 8
  15. /* SPI: */
  16. /* TODO: move to spi.h */
  17. #define SPI_DDR DDRB
  18. #define SPI_SCK_PIN PB5
  19. #define SPI_MOSI_PIN PB3
  20. #define SPI_MISO_PIN PB4
  21. char bool_case = 0;
  22. int timer = 0;
  23. int timer_max = 0;
  24. void Initialize_SPI(void);
  25. int main (void)
  26. {
  27. struct bme280_data sensorData;
  28. // uint8_t testRegisterContent = 0x0A;
  29. // uint8_t registerContent[5];
  30. // char registerContentString[30];
  31. // uint8_t lengthRead;
  32. /* Initialize the SPI */
  33. Initialize_SPI();
  34. /* Initialize the nrf24l01 */
  35. Initialize_NRF24L01();
  36. // The NRF24L01 is now in the mode Standby-I.
  37. /* Configure the transmission parameters (Enhanced ShockBurst)*/
  38. Configure_Transmission();
  39. /* Initialize the BME280 */
  40. Initialize_BME280();
  41. while(1)
  42. {
  43. BME280_Get_Measurement(&sensorData);
  44. NRF24L01_Send_Message((uint8_t*)&sensorData, sizeof(sensorData));
  45. _delay_ms(1000);
  46. }
  47. }
  48. void Initialize_SPI(void)
  49. {
  50. /* Set MOSI and SCK output, all others input */
  51. SPI_DDR = (1<<SPI_MOSI_PIN)|(1<<SPI_SCK_PIN);
  52. /* Enable SPI, Master, set clock rate fck/16 */
  53. SPCR = (1<<SPE)|(1<<MSTR);
  54. }