Exemple #1
0
/** Initializes the hardware and software associated with the V2 protocol command handling. */
void V2Protocol_Init(void)
{
	#if defined(ADC)
	/* Initialize the ADC converter for VTARGET level detection on supported AVR models */
	ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
	ADC_SetupChannel(VTARGET_ADC_CHANNEL);
	ADC_StartReading(VTARGET_REF_MASK | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
	#endif

	V2Params_LoadNonVolatileParamValues();

	#if defined(ENABLE_ISP_PROTOCOL)
	ISPTarget_ConfigureRescueClock();
	#endif
}
Exemple #2
0
/** Shuts down the current selected SPI driver (hardware or software, depending on the selected ISP speed) so that no
 *  further communications can occur until the driver is re-initialized.
 */
void ISPTarget_DisableTargetISP(void)
{
	if (HardwareSPIMode)
	{
		SPI_Disable();
	}
	else
	{
		DDRB  &= ~((1 << 1) | (1 << 2));
		PORTB &= ~((1 << 0) | (1 << 3));

		/* Must re-enable rescue clock once software ISP has exited, as the timer for the rescue clock is
		 * re-purposed for software SPI */
		ISPTarget_ConfigureRescueClock();
	}
}
Exemple #3
0
/** Initialises the hardware and software associated with the V2 protocol command handling. */
void V2Protocol_Init(void)
{
	#if defined(ADC)
	/* Initialize the ADC converter for VTARGET level detection on supported AVR models */
	ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
	ADC_SetupChannel(VTARGET_ADC_CHANNEL);
	ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
	#endif

	/* Timeout timer initialization (10ms period) */
	OCR0A  = (((F_CPU / 1024) / 100) - 1);
	TCCR0A = (1 << WGM01);
	TIMSK0 = (1 << OCIE0A);

	V2Params_LoadNonVolatileParamValues();
	
	#if defined(ENABLE_ISP_PROTOCOL)
	ISPTarget_ConfigureRescueClock();
	#endif
}
Exemple #4
0
/** Handler for the XPROG LEAVE_PROGMODE command to terminate the PDI programming connection with
 *  the attached device.
 */
static void XPROGProtocol_LeaveXPROGMode(void)
{
	Endpoint_ClearOUT();
	Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPADDR);
	Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);

	if (XPROG_SelectedProtocol == XPROG_PROTOCOL_PDI)
	  XMEGANVM_DisablePDI();
	else
	  TINYNVM_DisableTPI();

	#if defined(XCK_RESCUE_CLOCK_ENABLE) && defined(ENABLE_ISP_PROTOCOL)
	/* If the XCK rescue clock option is enabled, we need to restart it once the
	 * XPROG mode has been exited, since the XPROG protocol stops it after use. */
	ISPTarget_ConfigureRescueClock();
	#endif

	Endpoint_Write_8(CMD_XPROG);
	Endpoint_Write_8(XPROG_CMD_LEAVE_PROGMODE);
	Endpoint_Write_8(XPROG_ERR_OK);
	Endpoint_ClearIN();
}