Files
mongoose/examples/PIC32/mqtt_client/firmware/src/cc3100_port.c
T
Alexander Alashkin eaef5bd133 Revert "Stop publish examples to mongoose repo"
This reverts commit 1a17e17c462bdd4e1d26d8742f8b7087273e04c2.

PUBLISHED_FROM=80028de308c9a021955d1425d2bfee8feb85f193
2017-02-06 14:08:59 +00:00

68 lines
1.3 KiB
C

/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*/
#include "app.h"
#include "system/debug/sys_debug.h"
#include "simplelink.h"
#include "user_params.h"
P_EVENT_HANDLER g_cc3100_IRQ_handler = NULL;
void AssertCS() {
PLIB_PORTS_PinClear(PORTS_ID_0, CS_PORT, CS_PIN);
}
void DeassertCS() {
PLIB_PORTS_PinSet(PORTS_ID_0, CS_PORT, CS_PIN);
}
void CC3100_enable() {
PLIB_PORTS_PinSet(PORTS_ID_0, HIB_PORT, HIB_PIN);
}
void CC3100_disable() {
PLIB_PORTS_PinClear(PORTS_ID_0, HIB_PORT, HIB_PIN);
}
Fd_t spi_Open(char *ifName, unsigned long flags) {
CC3100_disable();
return 0;
}
int spi_Write(Fd_t fd, unsigned char *pBuff, int len) {
if (len > 512) {
SYS_PRINT("BUFFER TOO SMALL");
return 0;
}
AssertCS();
uint8_t dummy[512];
DRV_SPI0_BufferAddWriteRead(pBuff, dummy, len);
DRV_SPI_Tasks(sysObj.spiObjectIdx0);
DeassertCS();
return len;
}
int spi_Read(Fd_t fd, unsigned char *pBuff, int len) {
if (len > 512) {
SYS_PRINT("BUFFER TOO SMALL");
return 0;
}
uint8_t dummy[512];
memset(dummy, 0xFF, len);
AssertCS();
DRV_SPI0_BufferAddWriteRead(dummy, pBuff, len);
DRV_SPI_Tasks(sysObj.spiObjectIdx0);
DeassertCS();
return len;
}
int registerInterruptHandler(P_EVENT_HANDLER int_handler, void *pValue) {
(void) pValue;
g_cc3100_IRQ_handler = int_handler;
}