Exemple #1
0
void StartReceiveImages()
{
    uint16_t rowReceived = 0;
    uint16_t bytesInRowReceived = 0;
    uint16_t const bytesInARow = 720;

    while (true)
        {
            RefreshButtonState(&leftButton, NULL);
            RefreshButtonState(&rightButton, NULL);

            RefreshLEDState(false, LED_MAX_BRIGHTNESS);

            if (NRF24L01_DataReady())
            {
                NRF24L01_GetData(dataIn);

                if (!mem_cmp(startCommand, dataIn, 32))
                {
                    RefreshLEDState(true, LED_MAX_BRIGHTNESS);
                    Delay_ms(50);

                    _receivingImage = 1;
                    rowReceived = 0;
                    bytesInRowReceived = 0;

                    LCDInitializeDataSend();
                    continue;
                }

                if (_receivingImage)
                {
                    MemCopy(dataIn, rowData, 0, bytesInRowReceived, 32);
                    bytesInRowReceived += 32;

                    if (bytesInRowReceived >= bytesInARow)
                    {
                        LCDFillRow(rowData);
                        bytesInRowReceived = bytesInRowReceived - bytesInARow;
                        MemCopy(dataIn, rowData, bytesInRowReceived, 0, bytesInRowReceived);

                        rowReceived++;

                        if (rowReceived == 320)
                        {
                            RefreshLEDState(false, LED_MAX_BRIGHTNESS);

                            _receivingImage = 0;
                            rowReceived = 0;
                            bytesInRowReceived = 0;

                            LCDFinishDataSend();
                        }
                    }
                }
            }
        }
}
Exemple #2
0
void transmitter(void)
{
/* My address */
uint8_t MyAddress[] = {
   0xE7,
   0xE7,
   0xE7,
   0xE7,
   0xE7
};
/* Receiver address */
uint8_t TxAddress[] = {
   0x7E,
   0x7E,
   0x7E,
   0x7E,
   0x7E
};
uint8_t dataOut[32], dataIn[32], i;
uint32_t tr_count;
NRF24L01_Transmit_Status_t transmissionStatus;

   /* Initialize NRF24L01+ on channel 15 and 32bytes of payload */
   /* By default 2Mbps data rate and 0dBm output power */
   /* NRF24L01 goes to RX mode by default */
   NRF24L01_Init(15, 32);

   /* Set RF settings, Data rate to 2Mbps, Output power to -18dBm */
   NRF24L01_SetRF(NRF24L01_DataRate_2M, NRF24L01_OutputPower_M18dBm);

   /* Set my address, 5 bytes */
   //NRF24L01_SetMyAddress(MyAddress);
   /* Set TX address, 5 bytes */
   //NRF24L01_SetTxAddress(TxAddress);

   uint8_t reg;

   delay_(720000);


	reg = NRF24L01_ReadRegister(NRF24L01_REG_CONFIG);
	printf("NRF24L01_REG_CONFIG: 0x%X\r\n", reg);

	reg = NRF24L01_ReadRegister(NRF24L01_REG_EN_RXADDR);
	printf("NRF24L01_REG_EN_RXADDR: 0x%X\r\n", reg);

	reg = NRF24L01_ReadRegister(NRF24L01_REG_RF_CH);
	printf("NRF24L01_REG_RF_CH: 0x%X\r\n", reg);

	reg = NRF24L01_ReadRegister(NRF24L01_REG_CONFIG);
	printf("NRF24L01_REG_CONFIG: 0x%X\r\n", reg);

	reg = NRF24L01_ReadRegister(NRF24L01_REG_RF_CH);
		printf("NRF24L01_REG_RF_CH: 0x%X\r\n", reg);

		reg = NRF24L01_ReadRegister(NRF24L01_REG_CONFIG);
			printf("NRF24L01_REG_CONFIG: 0x%X\r\n", reg);

	delay_(720000);

   for (i = 0; i < 32; i++)
   {
      dataOut[i] = i + 30;
      dataIn[i] = 0;
   }
while (1) {
         /* Transmit data, goes automatically to TX mode */
         NRF24L01_Transmit(dataOut);
         /* Turn on led to indicate sending */
         LED2_ON;
         /* Wait for data to be sent */
         do {
            transmissionStatus = NRF24L01_GetTransmissionStatus();

            printf("transmissionStatus: %d\r\n", transmissionStatus);
            delay_(72000);

         } while (transmissionStatus == NRF24L01_Transmit_Status_Sending);
         /* Turn off led */
         LED2_OFF;

         /* Go back to RX mode */
         NRF24L01_PowerUpRx();
         i = 0;



         uint8_t status = NRF24L01_GetStatus();
         printf("status: %d\r\n", status);

         /* Wait received data, wait max 100ms, if time is larger, then data were probably lost */
         while (!NRF24L01_DataReady())
         {
            delay_(720000);
            i++;
            printf("TM_NRF24L01_DataReady\r\n");
            if( i > 100) break;
         }

         /* Get data from NRF2L01+ */
         NRF24L01_GetData(dataIn);

         printf("dataIn: %s\r\n", dataIn);

         /* Check transmit status */
         if (transmissionStatus == NRF24L01_Transmit_Status_Ok)
         {
            tr_count++;
            printf("tr_count: %s\r\n", tr_count);
         }

         delay_(7200000);
      }
}
Exemple #3
0
void retranslate(void)
{
/* Receiver address */
uint8_t TxAddress[] = {
   0xE7,
   0xE7,
   0xE7,
   0xE7,
   0xE7
};
/* My address */
uint8_t MyAddress[] = {
   0x7E,
   0x7E,
   0x7E,
   0x7E,
   0x7E
};


uint8_t dataIn[32];
NRF24L01_Transmit_Status_t transmissionStatus;
   /* Initialize NRF24L01+ on channel 15 and 32bytes of payload */
   /* By default 2Mbps data rate and 0dBm output power */
   /* NRF24L01 goes to RX mode by default */
   NRF24L01_Init(15, 32);

   /* Set RF settings, Data rate to 2Mbps, Output power to -18dBm */
   NRF24L01_SetRF(NRF24L01_DataRate_2M, NRF24L01_OutputPower_M18dBm);

   /* Set my address, 5 bytes */
   NRF24L01_SetMyAddress(MyAddress);
   /* Set TX address, 5 bytes */
   NRF24L01_SetTxAddress(TxAddress);

   LED1_ON;
   delay_(3600000);
   LED1_OFF;
      while (1)
      {
      /* If data is ready on NRF24L01+ */
      if (NRF24L01_DataReady())
         {
            /* Get data from NRF24L01+ */
            NRF24L01_GetData(dataIn);

            delay_(36000);

            /* Send it back, automatically goes to TX mode */
            NRF24L01_Transmit(dataIn);

            /* Start send */
            LED1_ON;;
            delay_(360000);
            /* Wait for data to be sent */
            do {
               transmissionStatus = NRF24L01_GetTransmissionStatus();
            } while (transmissionStatus == NRF24L01_Transmit_Status_Sending);
            /* Send done */
            LED1_OFF;

            /* Go back to RX Mode */
            NRF24L01_PowerUpRx();
         }
      }

}