Example #1
0
/*
** ===================================================================
**     Method      :  WAIT1_WaitLongCycles (component Wait)
**     Description :
**         Wait for a specified number of CPU cycles (32bit data type).
**     Parameters  :
**         NAME            - DESCRIPTION
**         cycles          - The number of cycles to wait.
**     Returns     : Nothing
** ===================================================================
*/
void WAIT1_WaitLongCycles(uint32_t cycles)
{
  while(cycles>60000) {
    WAIT1_WaitCycles(60000);
    cycles -= 60000;
  }
  WAIT1_WaitCycles((uint16_t)cycles);
}
Example #2
0
void Quick_Reset_Core()
{
	cc_strobe(TI_CCxxx0_SIDLE);
	WAIT1_WaitCycles(1000);
	cc_strobe(TI_CCxxx0_SFRX);      // Flush RXFIFO
	WAIT1_WaitCycles(1000);
	cc_strobe(TI_CCxxx0_SFTX);      // Flush RXFIFO
	WAIT1_WaitCycles(1000);
	cc_strobe(TI_CCxxx0_SRX);           // Initialize CCxxxx in RX mode.
}
Example #3
0
/*
** ===================================================================
**     Method      :  WAIT1_WaitLongCycles (component Wait)
**     Description :
**         Wait for a specified number of CPU cycles (32bit data type).
**     Parameters  :
**         NAME            - DESCRIPTION
**         cycles          - The number of cycles to wait.
**     Returns     : Nothing
** ===================================================================
*/
void WAIT1_WaitLongCycles(uint32_t cycles)
{
  /*lint -save -e522 function lacks side effect. */
  while(cycles>60000) {
    WAIT1_WaitCycles(60000);
    cycles -= 60000;
  }
  WAIT1_WaitCycles((uint16_t)cycles);
  /*lint -restore */
}
Example #4
0
uint8_t LIS2DH12TR_init(void){
	int8_t data, res;
	deviceData.handle = I2C1_Init(&deviceData);
	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_ReadReg(0x0f, &data, sizeof(data));	// I2C test line 1
		if (res!=ERR_OK) {
			return;
		} else if(data != 0x33){
			res = 0xff;	// eifach öppis
			return;
		}
	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_WriteReg(0x20, 0b10001111);
	if(res != ERR_OK){
		return;
	}
	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_WriteReg(0x23, 0b00100000);
	if(res!=ERR_OK) {
		return;
	}
	WAIT1_WaitCycles(25);
	return res;
}
Example #5
0
void accelTest(void){
	uint8_t res = ERR_OK;
	int8_t dataX = 0;

	deviceData.handle = I2C1_Init(&deviceData);

#if 0
	uint8_t data = 0;
	int8_t i = 2;




	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_ReadReg(0x0f, &data, sizeof(data));
	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_WriteReg(0x20, 0b01111111);
	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_WriteReg(0x23, 0b00100000);

	for(;;){
		WAIT1_WaitCycles(25);
		res = LIS2DH12TR_ReadReg(0x29, &dataX, 1U);

		if(dataX > i){
			LED1_On();
			i = -1;
		} else if(dataX < i){
			LED1_Off();
			i = 1;
		}
	}
#else

#define MASK_LED1	0x04
#define MASK_LED2	0x02
#define MASK_LED3	0x01
#define PIXEL_TIME_MS	1

	uint8_t img[] = {7,2,7,0,7,7,7,0,7,4,4,0,7,4,7};

	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_WriteReg(0x20, 0b01111111);
	WAIT1_WaitCycles(25);
	res = LIS2DH12TR_WriteReg(0x23, 0b00100000);
	WAIT1_WaitCycles(25);

	bool swipeRight = FALSE;
	bool swipeLeft = FALSE;

	uint8_t right = 0;
	uint8_t left = 0;

	uint8_t prevAccelValue = 0;
	uint8_t lengthOfImage = sizeof(img);

	while(1){
		//WAIT1_WaitCycles(25);
		WAIT1_Waitms(1);
		res = LIS2DH12TR_ReadReg(0x29, &dataX, 1U);

		if(dataX < prevAccelValue){
			right++;
			if(right == 3){
				swipeRight = TRUE;
				right = 0;
			}
		} /*else if(dataX > prevAccelValue){
			left++;
			if(left == 3){
				swipeLeft = TRUE;
				left = 0;
			}
		}*/
		prevAccelValue = dataX;

		if ((dataX > 40) & swipeRight){

			WAIT1_Waitms(10);

			for(int i=0; i<lengthOfImage; i++){
				LED1_Put(img[i] & MASK_LED1);
				LED2_Put(img[i] & MASK_LED2);
				LED3_Put(img[i] & MASK_LED3);

				WAIT1_Waitms(PIXEL_TIME_MS);

				LED1_Off();
				LED2_Off();
				LED3_Off();

				WAIT1_Waitms(PIXEL_TIME_MS);
			}
			swipeRight = FALSE;
		} /*else if ((dataX < 40) & swipeLeft){

			WAIT1_Waitms(10);

			for(int i=(lengthOfImage-1); i>=0; i--){
				LED1_Put(img[i] & MASK_LED1);
				LED2_Put(img[i] & MASK_LED2);
				LED3_Put(img[i] & MASK_LED3);

				WAIT1_Waitms(PIXEL_TIME_MS);

				LED1_Off();
				LED2_Off();
				LED3_Off();

				WAIT1_Waitms(PIXEL_TIME_MS);
			}
			swipeLeft = FALSE;
		}*/
		//prevAccelValue = 0;
	}
#endif
}