X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Flpc%2Fao_arch_funcs.h;h=dbb415381ce28c980cf78f31da38ada52fad1f55;hb=7348cc4736c9a94f9ad299edd78199b544d0e95a;hp=96ae0366f85bee03eb9caa0a5bf8718ade483975;hpb=ac089d4fb930b7dbc4161259fd9bddba94395ebc;p=fw%2Faltos diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h index 96ae0366..dbb41538 100644 --- a/src/lpc/ao_arch_funcs.h +++ b/src/lpc/ao_arch_funcs.h @@ -22,30 +22,68 @@ #define ao_spi_put_bit(reg,bit,pin,bus) ao_spi_put_mask(reg,(1<dr = byte; + while ((lpc_ssp->sr & (1 << LPC_SSP_SR_RNE)) == 0); + (void) lpc_ssp->dr; +} + +#define ao_spi_init_cs(port, mask) do { \ + uint8_t __bit__; \ + for (__bit__ = 0; __bit__ < 32; __bit__++) { \ + if (mask & (1 << __bit__)) \ + ao_enable_output(port, __bit__, PIN, 1); \ + } \ + } while (0) + +#define HAS_ARCH_START_SCHEDULER 1 + +static inline void ao_arch_start_scheduler(void) { + uint32_t sp; + uint32_t control; + + asm("mrs %0,msp" : "=&r" (sp)); + asm("msr psp,%0" : : "r" (sp)); + asm("mrs %0,control" : "=&r" (control)); + control |= (1 << 1); + asm("msr control,%0" : : "r" (control)); + asm("isb"); +} + #endif /* _AO_ARCH_FUNCS_H_ */