You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CubeSatSim/libs/libmf/source/offxosc.c

34 lines
620 B

#include "ax8052.h"
#include "libmfosc.h"
/**
* \brief turn off XOSC if accidentally enabled
*
*/
__reentrantb void turn_off_xosc(void) __reentrant
{
uint8_t iesave, portasave, dirasave, xtalreadysave, i;
if (SILICONREV != SILICONREVISION_V1 && (MISCCTRL & 0x02))
return;
MISCCTRL |= 0x02;
iesave = IE & 0x80;
EA = 0;
portasave = PORTA;
dirasave = DIRA;
xtalreadysave = XTALREADY;
XTALREADY = 0x00;
PORTA_0 = 1;
PORTA_1 = 0;
DIRA |= 0x03;
OSCFORCERUN &= (uint8_t)~0x04;
i = 6;
do {
PORTA ^= 0x03;
} while (--i);
DIRA = dirasave;
PORTA = portasave;
XTALREADY = xtalreadysave;
IE |= iesave;
}

Powered by TurnKey Linux.