Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

main.c 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //#define F_CPU 1000000UL // Frequenz des Quarzes, ohne Quarz standardmäßig 1MHz
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #include <stdint.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "nrf24l01.h"
  9. #include "nrf24l01_definitions.h"
  10. #include "uart_debug.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. #define SPI_DDR DDRB
  17. #define SPI_SCK_PIN PB1
  18. #define SPI_MOSI_PIN PB2
  19. #define SPI_MISO_PIN PB3
  20. /* NRF24L01 */
  21. /*
  22. * CS: pin 9
  23. * CE: pin 8
  24. * IRQ: pin 7
  25. */
  26. char bool_case = 0;
  27. int timer = 0;
  28. int timer_max = 0;
  29. void Initialize_SPI(void);
  30. int main (void)
  31. {
  32. char debugString[50] = "";
  33. // uint8_t testRegisterContent = 0x0A;
  34. // uint8_t registerContent[5];
  35. // char registerContentString[30];
  36. // uint8_t lengthRead;
  37. /* Set baud rate */
  38. Initialize_UART(51);
  39. sprintf(debugString, "%s\r\n", "Program start");
  40. Print_Debug_String(debugString);
  41. /* Initialize the SPI */
  42. Initialize_SPI();
  43. /* Initialize the nrf24l01 */
  44. Initialize_NRF24L01();
  45. // The NRF24L01 is now in the mode Standby-I.
  46. /* Configure the transmission parameters (Enhanced ShockBurst)*/
  47. Configure_Transmission();
  48. // sprintf(debugString, "%s\r\n", "program end");
  49. // Print_Debug_String(debugString);
  50. while(1)
  51. {
  52. Send_Test_Message();
  53. sprintf(debugString, "%s\r\n", "test message");
  54. Print_Debug_String(debugString);
  55. _delay_ms(1000);
  56. }
  57. }
  58. void Initialize_SPI(void)
  59. {
  60. /* Set MOSI and SCK output, all others input */
  61. SPI_DDR = (1<<SPI_MOSI_PIN)|(1<<SPI_SCK_PIN);
  62. /* Enable SPI, Master, set clock rate fck/16 */
  63. SPCR = (1<<SPE)|(1<<MSTR);
  64. }