int
main(int argc, char *argv[])
{
  int res, i;
  char myname[256];
  unsigned int addr, laddr;
  int slot = 0, nssp = 0;

  printf("\n");
  if(argc==2||argc==3)
  {
    strncpy(myname, argv[1], 255);
    printf("Use argument >%s< as bin file name\n",myname);
    if(argc==3)
	{
	  slot = atoi(argv[2]);
      printf("Upgrade board at slot=%d only\n",slot);
	}
	else
	{
      slot = 0;
      printf("Upgrade all boards in crate\n");
	}
  }
  else
  {
    printf("Usage: sspfirmware <bin file> [slot]\n");
    exit(0);
  }
  printf("\n");

  /* Open the default VME windows */
  vmeOpenDefaultWindows();
  printf("\n");

  if(slot)
  {
    sspInit(slot<<19, 0, 1, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
    sspRich_Init(slot);
//    sspRich_FirmwareUpdateVerifyAll(slot, myname);
    sspRich_FirmwareVerifyAll(slot, myname);
  }
  else
  {
    sspInit(0, 0, 0, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
    nssp = sspGetNssp();
    for(i=0; i<nssp; i++)
    {
      slot = sspSlot(i);
      if(sspGetFirmwareType(slot) == SSP_CFG_SSPTYPE_HALLBRICH)
      {
        sspRich_Init(slot);
//        sspRich_FirmwareUpdateVerifyAll(slot, myname);
        sspRich_FirmwareVerifyAll(slot, myname);
      }
    }
  }

  exit(0);
}
Beispiel #2
0
int main(void) 
{
	// don't know why this is incorrect
	SystemCoreClock = 100000000;
	SysTick_Config(SystemCoreClock / 1000);

	timeout_ms=0;
	
	UART0_Init(115200);


	sspInit();
	lcdInit();


	// sets SystemCoreClock to 44583722, but why ? 
	SystemCoreClockUpdate();


	lcd_plot (1, 1, 1);
	lcd_putc (1,1,'c',1);


	while(1)
	{
	}
}
Beispiel #3
0
//Initializes the SPI module of the AVR to work with the NORDIC
void init_nordic_spi() {

	//Configure IO Directions
	// config CSN pin
	IOCON_JTAG_TDO_PIO1_1 &= ~IOCON_JTAG_TDO_PIO1_1_FUNC_MASK;
	IOCON_JTAG_TDO_PIO1_1 |= IOCON_JTAG_TDO_PIO1_1_FUNC_GPIO;
    gpioSetDir(1, NORDIC_CSN, gpioDirection_Output);
	// config CE pin
	IOCON_JTAG_nTRST_PIO1_2 &= ~IOCON_JTAG_nTRST_PIO1_2_FUNC_MASK;
	IOCON_JTAG_nTRST_PIO1_2 |= IOCON_JTAG_nTRST_PIO1_2_FUNC_GPIO;
    gpioSetDir(1, NORDIC_CE, gpioDirection_Output);
	// config IRQ pin - needs to be input actually.
	IOCON_JTAG_TMS_PIO1_0 &= ~IOCON_JTAG_TMS_PIO1_0_FUNC_MASK;
	IOCON_JTAG_TMS_PIO1_0 |= IOCON_JTAG_TMS_PIO1_0_FUNC_GPIO;
    
	//Edited to be input
	gpioSetDir(1, NORDIC_IRQ, gpioDirection_Input);
	

	//Drive nCS HIGH
	NORDIC_CSN_HIGH();

	//Configure UART1 in SPI MODE
	//CPOL and CPHA both at 0? 
	//SCK should normally be low. And the clock samples data in the middle of data bits, 
	sspInit (0, sspClockPolarity_Low, sspClockPhase_RisingEdge);

	timer16Init(0, TIMER16_DEFAULTINTERVAL);
}
Beispiel #4
0
void nrf_init() {
    // Enable SPI correctly
    sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);

    // Enable CS & CE pins
    gpioSetDir(RB_SPI_NRF_CS, gpioDirection_Output);
    gpioSetPullup(&RB_SPI_NRF_CS_IO, gpioPullupMode_Inactive);
    gpioSetDir(RB_NRF_CE, gpioDirection_Output);
    gpioSetPullup(&RB_NRF_CE_IO, gpioPullupMode_PullUp);
    CE_LOW();

    // Setup for nrf24l01+
    // power up takes 1.5ms - 3.5ms (depending on crystal)
    CS_LOW();
    nrf_write_reg(R_CONFIG,
            R_CONFIG_PRIM_RX| // Receive mode
            R_CONFIG_PWR_UP|  // Power on
            R_CONFIG_EN_CRC   // CRC on, single byte
            );
    
    nrf_write_reg(R_EN_AA, 0); // Disable Enhanced ShockBurst;

    // Set speed / strength
    nrf_write_reg(R_RF_SETUP,DEFAULT_SPEED|R_RF_SETUP_RF_PWR_3);

    // Clear MAX_RT, just in case.
    nrf_write_reg(R_STATUS,R_STATUS_MAX_RT);
};
DSTATUS dataflash_initialize() {
    sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);

    gpioSetDir(RB_SPI_CS_DF, gpioDirection_Output);

    dataflash_resume();
    status &= ~STA_NOINIT;
    return status;
}
Beispiel #6
0
void avrspi_select(void) {
	// init the ssp on SPI port 0 (SPI1 would be awesome)
	sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);

	// set ssp clock divider so avr can handle bus speed (see avr.h)
	SCB_SSP0CLKDIV = AVR_DIVIDER;
	
	// set direction of RESET to output and bring hi (off)
	avrspi_setReset(1);
	gpioSetDir(AVR_RESET, gpioDirection_Output);
	avrspi_setReset(1);
}
int
main(int argc, char *argv[])
{
  int res;
  char myname[256];
  unsigned int addr, laddr;
  int slot = 0;

  printf("\n");
  if(argc==2||argc==3)
  {
    strncpy(myname, argv[1], 255);
    printf("Use argument >%s< as bin file name\n",myname);
    if(argc==3)
	{
	  slot = atoi(argv[2]);
      printf("Upgrade board at slot=%d only\n",slot);
	}
	else
	{
      slot = 0;
      printf("Upgrade all boards in crate\n");
	}
  }
  else
  {
    printf("Usage: sspfirmware <bin file> [slot]\n");
    exit(0);
  }
  printf("\n");

  /* Open the default VME windows */
  vmeOpenDefaultWindows();
  printf("\n");

  if(slot)
  {
    sspInit(slot<<19, 0, 1, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
    sspFirmwareRead(slot, myname);
//    sspFirmwareUpdateVerify(slot, myname);
  }
  else
  {
    printf("Error: Must specifiy slot number\n");
//    sspInit(0, 0, 0, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK);
//    sspGFirmwareUpdateVerify(myname);
  }

  exit(0);
}
Beispiel #8
0
void switch_nordic(void) {
	/*
	uint32_t configReg = ( SSP_SSP0CR0_DSS_8BIT   // Data size = 8-bit
                  | SSP_SSP0CR0_FRF_SPI           // Frame format = SPI
                  | SSP_SSP0CR0_SCR_8);           // Serial clock rate = 8
  
    // Set clock polarity
      configReg &= ~SSP_SSP0CR0_CPOL_MASK;    // Clock polarity = Low between frames
  
    // Set edge transition
       //configReg |= SSP_SSP0CR0_CPHA_SECOND;  // Clock Phase = data transition on falling edge
	   configReg &= ~SSP_SSP0CR0_CPHA_MASK;    // Clock out phase = Leading edge clock transition
	   
    // Assign config values to SSP0CR0
    SSP_SSP0CR0 = configReg;
	*/
	
	sspInit (0, sspClockPolarity_Low, sspClockPhase_RisingEdge);

}
void at25Init (void)
{
  sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);
}
Beispiel #10
0
void lcdInit(void) {
    int id;

    sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);

    gpioSetValue(RB_LCD_CS, 1);
    gpioSetValue(RB_LCD_RST, 1);

    gpioSetDir(RB_LCD_CS, gpioDirection_Output);
    gpioSetDir(RB_LCD_RST, gpioDirection_Output);

    delayms(100);
    gpioSetValue(RB_LCD_RST, 0);
    delayms(100);
    gpioSetValue(RB_LCD_RST, 1);
    delayms(100);

    id=lcdRead(220); // ID3
    
    if(id==14)
        displayType=DISPLAY_N1600;
    else /* ID3 == 48 */
        displayType=DISPLAY_N1200;
    
/* Small Nokia 1200 LCD docs:
 *           clear/ set
 *  on       0xae / 0xaf
 *  invert   0xa6 / 0xa7
 *  mirror-x 0xA0 / 0xA1
 *  mirror-y 0xc7 / 0xc8
 *
 *  0x20+x contrast (0=black - 0x2e)
 *  0x40+x offset in rows from top (-0x7f)
 *  0x80+x contrast? (0=black -0x9f?)
 *  0xd0+x black lines from top? (-0xdf?)
 *
 */
    lcd_select();

    if(displayType==DISPLAY_N1200){
        uint8_t initseq[]= { 0xE2,0xAF, // Display ON
                             0xA1, // Mirror-X
                             0xA4, 0x2F, 0xB0, 0x10};
        int i = 0;
        while(i<sizeof(initseq)){
            lcdWrite(TYPE_CMD,initseq[i++]);
            delayms(5); // actually only needed after the first
        }
    }else{ /* displayType==DISPLAY_N1600 */
        uint8_t initseq_d[] = {  
                               0x36,
                               0x29, 0xBA, 0x07,
                               0x15, 0x25, 0x3f,
                               0x11, 0x13, 0x37,
                               0x00, 0x3A, 0x05,
                               0x2A, 0, 98-1,
                               0x2B, 0, 70-1};
        uint32_t initseq_c = ~ 0x12BA7; // command/data bitstring
        int i = 0;
        lcdWrite(TYPE_CMD,0x01); //sw reset
        delayms(10);

        while(i<sizeof(initseq_d)){
            lcdWrite(initseq_c&1, initseq_d[i++]);
            initseq_c = initseq_c >> 1;
        }
    }
    lcd_deselect();
}