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/offlpxosc.c

35 lines
588 B

#include "ax8052.h"
#include "libmfosc.h"
/**
* \brief turn off LPXOSC if accidentally enabled
*
*/
__reentrantb void turn_off_lpxosc(void) __reentrant
{
uint8_t iesave, portasave, dirasave, i;
if (SILICONREV != SILICONREVISION_V1 && (MISCCTRL & 0x01))
return;
MISCCTRL |= 0x01;
iesave = IE & 0x80;
EA = 0;
portasave = PORTA;
dirasave = DIRA;
PORTA_4 = 1;
PORTA_5 = 0;
DIRA |= 0x18;
OSCFORCERUN &= (uint8_t)~0x08;
i = 6;
do {
uint8_t j = 0x80;
do {
nop();
} while (--j);
PORTA ^= 0x18;
} while (--i);
DIRA = dirasave;
PORTA = portasave;
IE |= iesave;
}

Powered by TurnKey Linux.