Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support iS110B typeC module #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/GS2200Hal.cpp
Expand Up @@ -40,6 +40,7 @@

//#define GS_DEBUG

static int GPIO37 = 27;

/*-------------------------------------------------------------------------*
* Globals:
Expand All @@ -50,7 +51,6 @@ uint32_t ESCBufferCnt = 0;
uint8_t pendingDataFlag = 0;



/*---------------------------------------------------------------------------*
* msDelta
*---------------------------------------------------------------------------*
Expand All @@ -71,12 +71,23 @@ uint32_t msDelta(uint32_t start)


/*---------------------------------------------------------------------------*
* Init_GS2200_SPI
* Init_GS2200_SPI with type
*---------------------------------------------------------------------------*
* Function: Initialize GS2200 SPI
*---------------------------------------------------------------------------*/
void Init_GS2200_SPI(void)
void Init_GS2200_SPI_type(ModuleType type)
{
switch(type) {
case iS110B_TypeC:
puts("Is Your module iS110B_TypeC ?");
GPIO37 = 20;
break;
default:
puts("Is Your module iS110B_TypeA or iS110B_TypeB ?");
GPIO37 = 27;
break;
}

/* Start the SPI library for GS2200 control*/
SPI_PORT.begin();
/* Set GPIO37 monitor pin */
Expand All @@ -87,6 +98,17 @@ void Init_GS2200_SPI(void)
ConsoleLog( "GS2200 is ready to go." );
}

/*---------------------------------------------------------------------------*
* Init_GS2200_SPI
*---------------------------------------------------------------------------*
* Function: Initialize GS2200 SPI for compatibility
*---------------------------------------------------------------------------*/
void Init_GS2200_SPI(void)
{
/* Start the SPI library for GS2200 control*/
Init_GS2200_SPI_type(iS110B_TypeA);

}

/*-----------------------------------------------------------------------------*
* Get_GPIO37Status
Expand All @@ -97,7 +119,7 @@ void Init_GS2200_SPI(void)
*-----------------------------------------------------------------------------*/
int Get_GPIO37Status(void)
{
return digitalRead( GPIO37 );
return digitalRead( GPIO37 );
}


Expand Down Expand Up @@ -229,7 +251,7 @@ SPI_RESP_STATUS_E WiFi_Write(const void *txData, uint16_t dataLength)
ConsolePrintf( "hiResponse[5]:0x%x\r\n", hiResponse[5] );
ConsolePrintf( "hiResponse[6]:0x%x\r\n", hiResponse[6] );
ConsolePrintf( "recvLen:%d\r\n", recvLen );
#endif
#endif
return SPI_RESP_STATUS_ERROR;
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/GS2200Hal.h
Expand Up @@ -18,15 +18,13 @@
#ifndef _GS_HAL_H_
#define _GS_HAL_H_


#define MAX_RECEIVED_DATA 1500
#define SPI_MAX_RECEIVED_DATA 1500

#define SPI_PORT SPI5 /* SPRESENSE Main Board SPI */
#define SPI_FREQ 4000000 /* SPI Clock Frequency */
#define SPI_MODE SPI_MODE1 /* SPI_MODE0, SPI_MODE1, SPI_MODE3 */
#define SPI_DATA_TRANSFER SPI_PORT.transfer
#define GPIO37 27 /* GS2200 GPIO37 Monitor */

#define SPI_TIMEOUT 20000 /* wait for GPIO37 for this period */

Expand All @@ -37,12 +35,19 @@ typedef enum {
SPI_RESP_STATUS_TIMEOUT
} SPI_RESP_STATUS_E;

typedef enum {
iS110B_TypeA = 0,
iS110B_TypeB,
iS110B_TypeC,
} ModuleType;


/*-------------------------------------------------------------------------*
* Function ProtoTypes:
*-------------------------------------------------------------------------*/
uint32_t msDelta(uint32_t start);
void Init_GS2200_SPI(void);
void Init_GS2200_SPI_type(ModuleType type);

int Get_GPIO37Status(void);

Expand Down