Exemple #1
0
void takemeasurement(uint8_t * inbuf, uint8_t * outbuf)
{
	  // Start single measurement mode
	  outbuf[0] = 62;	// 0011zyxt
	  send_SPI(inbuf, 1, outbuf, 1);
	  //dbg_uartout(inbuf, outbuf, msg);

	  while(!HAL_GPIO_ReadPin(COMP_INT_P, COMP_INT));

	  //Read measurement
	  outbuf[0] = 78;
	  send_SPI(inbuf, 7, outbuf, 1);
	  //dbg_uartout(inbuf, outbuf, msg);
}
Exemple #2
0
uint32_t get_TI_CDCE18005(enum CDCE18005 which_register){
    uint32_t get_reg_value = 0;
    get_reg_value = (0xf0 & which_register << 4) | Read_Command;

    // This tells the TI chip to send us the reg. value requested
    send_SPI(get_reg_value);
    return receive_SPI();
}
Exemple #3
0
void ledMatrix(void)
{
	static tU32 columnCounter = 0x01;
 	static tU8 index = 0;

  if (columnCounter > 0x80)
  {
    columnCounter = 0x01;
    index = 0;
  }
  send_SPI(~pattern[index++]);
  send_SPI(~columnCounter);
  columnCounter <<= 1;

  T1IR        = 0xff;        //reset all IRQ flags
  VICVectAddr = 0x00;        //dummy write to VIC to signal end of interrupt
}
Exemple #4
0
void setup_TI_CDCE18005(enum TI_Input_10_MHz which_input) {
    // Send the table of data to init the clock distribution chip.  Uses SPI.
    uint32_t temp;

    if(which_input == Primary_GPS) {
        for(uint8_t i=0; i<table_size; i++){
            temp = table_Pri_Ref[i]<<4;
            temp |= i;
            send_SPI(temp); // Make sure the register's address is in the LSBs
        }
    } else {
        // is Secondary_Ext -- External 10 MHz input from SMA connector
        for(uint8_t i=0; i<table_size; i++){
            temp = table_Sec_Ref[i]<<4;
            temp |= i;
            // Make sure the register's address is in the LSBs
            send_SPI(temp);
         }
    }
}
Exemple #5
0
void timer_callback(void)
{
    uint8 data[3];

    data[0] = 'a';
    data[1] = 'b';
    data[2] = 'c';

    //send some SPI data
    send_SPI(SPI_CH_1, data, sizeof(data));
    
    
}
Exemple #6
0
int getData(char port)
{
	unsigned char d[2];
	char t = 0;
	*d = 0x0000;

	PEOUT ^= 0x80;
	send_SPI(port); // Channel 3 - vRef
    t=100; while(--t);                      // Delay >5us
	read_SPI(&d);
	PEOUT = 0xFF;

	return (int)*d;
}
Exemple #7
0
void test_SPI()
{
	char t = 0;
	unsigned char d[2];
	d[0] = 0x00;
	d[1] = 0x00;

	PEOUT ^= 0x80;
	send_SPI(0x1A); // Channel 3 - vRef
	waitForFullBuf();
    //t=0xFF; while(--t);                      // Delay >5us
	read_SPI(&d);
	writeData(d[0], d[1], d[0]);
	PEOUT = 0xFF;
}
Exemple #8
0
/* USER CODE BEGIN 4 */
void StartCompassTask(void const * argument)
{

	uint8_t inbuf[7];
	uint8_t outbuf[2];
	int16_t xyz[3];
	int16_t minmaxxyz[6];	// xmin xmax ymin ymax zmin zmax
	int16_t angle;
	uint8_t * msg = malloc(10);

	// Reset: 11110000 = 0xf0
	outbuf[0] = 0xf0;
	send_SPI(inbuf, 1, outbuf, 1);
	dbg_uartout(inbuf, outbuf, msg);

	calibrate(inbuf, outbuf, xyz, minmaxxyz);

	/*
	// Read register 0
	outbuf[0] = 80;
	outbuf[1] = 0 << 2;
	send_SPI(inbuf, 3, outbuf, 2);
	dbg_uartout(inbuf, outbuf, msg);
	*/


  /* Infinite loop */

  for(;;)
  {
	  takemeasurement(inbuf, outbuf);
	  processInput(inbuf, xyz, minmaxxyz);
	  getAngle(&angle, xyz);
	  compass_uart(xyz, msg, &angle);
	  osDelay(100);	// replace w/sleep
  }
#pragma GCC pop_options
}
Exemple #9
0
/** Sends and receives data through the SPI interface
 * 
 * @param data Data to be send through the SPI interface
 * 
 * @return Data received through the SPI interface
 * */
word tranfer_SPI(word data){
	send_SPI(data);													/* Send data */
	return get_SPI();												/* Receive data */
}
Exemple #10
0
void set_TI_CDCE18005(CDCE18005 which_register, uint32_t bits){
    send_SPI((bits << 4) | which_register);
}