image/svg+xml
Brteve's API for EveApps
Version 0.0.1
The reference document for common folder of EveApps project.
 
Loading...
Searching...
No Matches
EVE_HalImpl_FT9XX.c File Reference

Eve_Hal framework APIs for FT9XX host platform. More...

#include "EVE_HalImpl.h"
#include "EVE_Platform.h"

Go to the source code of this file.

Macros

#define GPIO_SS_NB   (sizeof(s_SpimGpioSS) / sizeof(s_SpimGpioSS[0]))
 

Functions

MISC
void ticker ()
 Clear the interrupt and increment the counter.
 
static void initSdHost ()
 Sdcard initialization.
 
void EVE_Mcu_initialize ()
 Init FT9x host MCU.
 
void EVE_Mcu_release ()
 Release FT9x host MCU.
 
void EVE_Millis_initialize ()
 Init FT9x timer.
 
void EVE_Millis_release ()
 Release FT9x timer.
 
uint32_t EVE_millis ()
 Get clock in miliseond.
 
uint64_t EVE_millis64 ()
 Get clock in miliseond.
 
void EVE_sleep (uint32_t ms)
 Sleep in milisecond.
 
bool EVE_UtilImpl_bootupDisplayGpio (EVE_HalContext *phost)
 Display GPIO pins.
 
INIT
void EVE_HalImpl_initialize ()
 Initialize HAL platform.
 
void EVE_HalImpl_release ()
 Release HAL platform.
 
EVE_HAL_EXPORT size_t EVE_Hal_list ()
 List the available devices.
 
EVE_HAL_EXPORT void EVE_Hal_info (EVE_DeviceInfo *deviceInfo, size_t deviceIdx)
 Get info of the specified device. Devices of type EVE_HOST_UNKNOWN should be ignored.
 
EVE_HAL_EXPORT bool EVE_Hal_isDevice (EVE_HalContext *phost, size_t deviceIdx)
 Check whether the context is the specified device.
 
bool EVE_HalImpl_defaults (EVE_HalParameters *parameters, size_t deviceIdx)
 Get the default configuration parameters.
 
void setSPI (EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
 Set number of SPI channel.
 
bool EVE_HalImpl_open (EVE_HalContext *phost, const EVE_HalParameters *parameters)
 Opens a new HAL context using the specified parameters.
 
void EVE_HalImpl_close (EVE_HalContext *phost)
 Close a HAL context.
 
void EVE_HalImpl_idle (EVE_HalContext *phost)
 Idle. Call regularly to update frequently changing internal state.
 
TRANSFER
void EVE_Hal_startTransfer (EVE_HalContext *phost, EVE_TRANSFER_T rw, uint32_t addr)
 Start data transfer to Coprocessor.
 
void EVE_Hal_endTransfer (EVE_HalContext *phost)
 End data transfer.
 
void EVE_Hal_flush (EVE_HalContext *phost)
 Flush data to Coprocessor.
 
static void rdBuffer (EVE_HalContext *phost, uint8_t *buffer, uint32_t size)
 Read a block data from Coprocessor.
 
static void wrBuffer (EVE_HalContext *phost, const uint8_t *buffer, uint32_t size)
 Write a block data to Coprocessor.
 
static uint8_t transfer8 (EVE_HalContext *phost, uint8_t value)
 Write 8 bit to Coprocessor.
 
uint8_t EVE_Hal_transfer8 (EVE_HalContext *phost, uint8_t value)
 Write 8 bits to Coprocessor.
 
uint16_t EVE_Hal_transfer16 (EVE_HalContext *phost, uint16_t value)
 Write 2 bytes to Coprocessor.
 
uint32_t EVE_Hal_transfer32 (EVE_HalContext *phost, uint32_t value)
 Write 4 bytes to Coprocessor.
 
void EVE_Hal_transferMem (EVE_HalContext *phost, uint8_t *result, const uint8_t *buffer, uint32_t size)
 Transfer (read/write) a block data to Coprocessor.
 
void EVE_Hal_transferProgMem (EVE_HalContext *phost, uint8_t *result, eve_progmem_const uint8_t *buffer, uint32_t size)
 Transfer a block data from program memory.
 
uint32_t EVE_Hal_transferString (EVE_HalContext *phost, const char *str, uint32_t index, uint32_t size, uint32_t padMask)
 Transfer a string to EVE platform.
 
UTILITY
void EVE_Hal_hostCommand (EVE_HalContext *phost, uint8_t cmd)
 Send a host command to Coprocessor.
 
void EVE_Hal_hostCommandExt3 (EVE_HalContext *phost, uint32_t cmd)
 This API sends a 3byte command to the phost.
 
bool EVE_Hal_powerCycle (EVE_HalContext *phost, bool up)
 Toggle PD_N pin of FT800 board for a power cycle.
 
void EVE_Hal_setSPI (EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
 Set number of SPI channel.
 
void EVE_Hal_restoreSPI (EVE_HalContext *phost)
 
uint32_t EVE_Hal_currentFrequency (EVE_HalContext *phost)
 Get current system clock of Coprocessor.
 

Variables

static const uint8_t s_SpimGpioSS [4] = { GPIO_SPIM_SS0, GPIO_SPIM_SS1, GPIO_SPIM_SS2, 35 }
 
static const pad_dir_t s_SpimFuncSS [4] = { pad_spim_ss0, pad_spim_ss1, pad_spim_ss2, pad_spim_ss3 }
 
static uint32_t s_TotalMilliseconds = 0
 
static uint64_t s_TotalMilliseconds64 = 0
 

Detailed Description

Eve_Hal framework APIs for FT9XX host platform.

Author
Bridgetek
Date
2018

MIT License

Copyright (c) [2019] [Bridgetek Pte Ltd (BRTChip)]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file EVE_HalImpl_FT9XX.c.

Macro Definition Documentation

◆ GPIO_SS_NB

#define GPIO_SS_NB   (sizeof(s_SpimGpioSS) / sizeof(s_SpimGpioSS[0]))

Definition at line 44 of file EVE_HalImpl_FT9XX.c.

Function Documentation

◆ EVE_Hal_currentFrequency()

uint32_t EVE_Hal_currentFrequency ( EVE_HalContext phost)

Get current system clock of Coprocessor.

Parameters
phostPointer to Hal context
Returns
uint32_t Frequency of Coprocessor

Definition at line 650 of file EVE_HalImpl_FT9XX.c.

651{
652 uint32_t t0;
653 uint32_t t1;
654 int32_t r = 15625;
655
656 t0 = EVE_Hal_rd32(phost, REG_CLOCK); /* t0 read */
657
658 __asm__(
659 " move.l $r0,%0 \n\t"
660 " mul.l $r0,$r0,100 \n\t"
661 "1: \n\t"
662 " sub.l $r0,$r0,3 \n\t" /* Subtract the loop time = 4 cycles */
663 " cmp.l $r0,0 \n\t" /* Check that the counter is equal to 0 */
664 " jmpc gt, 1b \n\t"
665 : /* Outputs */
666 : "r"(r) /* Inputs */
667 : "$r0"); /* Using */
668
669 t1 = EVE_Hal_rd32(phost, REG_CLOCK); /* t1 read */
670 return ((t1 - t0) << 6); /* bitshift 6 places is the same as multiplying 64 */
671}
#define REG_CLOCK
EVE_HAL_EXPORT uint32_t EVE_Hal_rd32(EVE_HalContext *phost, uint32_t addr)
Read 4 bytes from Coprocessor's memory.
Definition EVE_Hal.c:189
int int32_t
unsigned int uint32_t

◆ EVE_Hal_endTransfer()

void EVE_Hal_endTransfer ( EVE_HalContext phost)

End data transfer.

Parameters
phostPointer to Hal context

Definition at line 291 of file EVE_HalImpl_FT9XX.c.

292{
294
295 spi_close(SPIM, phost->SpiCsPin);
296 phost->Status = EVE_STATUS_OPENED;
297}
@ EVE_STATUS_READING
Definition EVE_HalDefs.h:59
@ EVE_STATUS_OPENED
Definition EVE_HalDefs.h:58
@ EVE_STATUS_WRITING
Definition EVE_HalDefs.h:60
#define eve_assert(cond)
EVE_STATUS_T Status

◆ EVE_Hal_flush()

void EVE_Hal_flush ( EVE_HalContext phost)

Flush data to Coprocessor.

Parameters
phostPointer to Hal context

Definition at line 304 of file EVE_HalImpl_FT9XX.c.

305{
307 /* no-op */
308}

◆ EVE_Hal_hostCommand()

void EVE_Hal_hostCommand ( EVE_HalContext phost,
uint8_t  cmd 
)

Send a host command to Coprocessor.

Parameters
phostPointer to Hal context
cmdCommand to send

Definition at line 544 of file EVE_HalImpl_FT9XX.c.

545{
547
548 uint8_t hcmd[4] = { 0 };
549 hcmd[0] = cmd;
550 hcmd[1] = 0;
551 hcmd[2] = 0;
552 hcmd[3] = 0;
553
554 spi_open(SPIM, phost->SpiCsPin);
555 spi_writen(SPIM, hcmd, 3);
556 spi_close(SPIM, phost->SpiCsPin);
557}
unsigned char uint8_t
static ft_void_t ft_uint32_t * cmd
Definition FT_Gpu_Hal.h:184

◆ EVE_Hal_hostCommandExt3()

void EVE_Hal_hostCommandExt3 ( EVE_HalContext phost,
uint32_t  cmd 
)

This API sends a 3byte command to the phost.

Parameters
phostPointer to Hal context
cmdCommand to send

Definition at line 565 of file EVE_HalImpl_FT9XX.c.

566{
568
569 uint8_t hcmd[4] = { 0 };
570 hcmd[0] = cmd & 0xff;
571 hcmd[1] = (cmd >> 8) & 0xff;
572 hcmd[2] = (cmd >> 16) & 0xff;
573 hcmd[3] = 0;
574
575 spi_open(SPIM, phost->SpiCsPin);
576 spi_writen(SPIM, hcmd, 3);
577 spi_close(SPIM, phost->SpiCsPin);
578}

◆ EVE_Hal_info()

EVE_HAL_EXPORT void EVE_Hal_info ( EVE_DeviceInfo deviceInfo,
size_t  deviceIdx 
)

Get info of the specified device. Devices of type EVE_HOST_UNKNOWN should be ignored.

Parameters
deviceInfo
deviceIdx

Definition at line 87 of file EVE_HalImpl_FT9XX.c.

88{
89 memset(deviceInfo, 0, sizeof(EVE_DeviceInfo));
90 strcpy_s(deviceInfo->DisplayName, sizeof(deviceInfo->DisplayName), "FT9XX");
91 strcpy_s(deviceInfo->SerialNumber, sizeof(deviceInfo->SerialNumber), "FT9XX");
92 deviceInfo->Host = EVE_HOST_EMBEDDED;
93}
#define strcpy_s(dst, sz, src)
@ EVE_HOST_EMBEDDED
char DisplayName[256]
char SerialNumber[16]
EVE_HOST_T Host

◆ EVE_Hal_isDevice()

EVE_HAL_EXPORT bool EVE_Hal_isDevice ( EVE_HalContext phost,
size_t  deviceIdx 
)

Check whether the context is the specified device.

Parameters
phostPointer to Hal context
deviceIdx
Returns
true True if ok
false False if error

Definition at line 103 of file EVE_HalImpl_FT9XX.c.

104{
105 return true;
106}

◆ EVE_Hal_list()

EVE_HAL_EXPORT size_t EVE_Hal_list ( )

List the available devices.

List the available devices

Definition at line 76 of file EVE_HalImpl_FT9XX.c.

77{
78 return 1;
79}

◆ EVE_Hal_powerCycle()

bool EVE_Hal_powerCycle ( EVE_HalContext phost,
bool  up 
)

Toggle PD_N pin of FT800 board for a power cycle.

Parameters
phostPointer to Hal context
upUp or Down
Returns
true True if ok
false False if error

Definition at line 588 of file EVE_HalImpl_FT9XX.c.

589{
590 if (up)
591 {
592 gpio_write(phost->PowerDownPin, 0);
593 EVE_sleep(20);
595 gpio_write(phost->PowerDownPin, 1);
596 EVE_sleep(20);
597 }
598 else
599 {
600 gpio_write(phost->PowerDownPin, 1);
601 EVE_sleep(20);
602 gpio_write(phost->PowerDownPin, 0);
603 EVE_sleep(20);
604 }
605 return true;
606}
@ EVE_SPI_SINGLE_CHANNEL
void setSPI(EVE_HalContext *phost, EVE_SPI_CHANNELS_T numchnls, uint8_t numdummy)
Set number of SPI channel.
void EVE_sleep(uint32_t ms)
Sleep in milisecond.
uint8_t PowerDownPin

◆ EVE_Hal_restoreSPI()

void EVE_Hal_restoreSPI ( EVE_HalContext phost)

Restore platform to previously configured EVE SPI channel mode

Definition at line 636 of file EVE_HalImpl_FT9XX.c.

637{
638 if (EVE_CHIPID < EVE_FT810)
639 return;
640
641 setSPI(phost, phost->SpiChannels, phost->SpiDummyBytes);
642}
#define EVE_CHIPID
#define EVE_FT810
Definition EVE_Config.h:58
EVE_SPI_CHANNELS_T SpiChannels
uint8_t SpiDummyBytes

◆ EVE_Hal_setSPI()

void EVE_Hal_setSPI ( EVE_HalContext phost,
EVE_SPI_CHANNELS_T  numchnls,
uint8_t  numdummy 
)

Set number of SPI channel.

Parameters
phostPointer to Hal context
numchnlsNumber of channel
numdummyNumber of dummy bytes

Definition at line 615 of file EVE_HalImpl_FT9XX.c.

616{
617 if (EVE_CHIPID < EVE_FT810)
618 return;
619
620 uint8_t writebyte = 0;
621
622 if ((numchnls > EVE_SPI_QUAD_CHANNEL) || (numdummy > 2) || (numdummy < 1))
623 return; // error
624
625 // Switch EVE to multi channel SPI mode
626 writebyte = numchnls;
627 if (numdummy == 2)
628 writebyte |= EVE_SPI_TWO_DUMMY_BYTES;
629 EVE_Hal_wr8(phost, REG_SPI_WIDTH, writebyte);
630 EVE_Hal_flush(phost);
631
632 // Switch FT9XX to multi channel SPI mode
633 setSPI(phost, numchnls, numdummy);
634}
#define REG_SPI_WIDTH
@ EVE_SPI_TWO_DUMMY_BYTES
@ EVE_SPI_QUAD_CHANNEL
EVE_HAL_EXPORT void EVE_Hal_wr8(EVE_HalContext *phost, uint32_t addr, uint8_t v)
Write 8 bits to Coprocessor's memory.
Definition EVE_Hal.c:220
void EVE_Hal_flush(EVE_HalContext *phost)
Flush data to Coprocessor.

◆ EVE_Hal_startTransfer()

void EVE_Hal_startTransfer ( EVE_HalContext phost,
EVE_TRANSFER_T  rw,
uint32_t  addr 
)

Start data transfer to Coprocessor.

Parameters
phostPointer to Hal context
rwRead or Write
addrAddress to read/write

Definition at line 257 of file EVE_HalImpl_FT9XX.c.

258{
260
261 if (rw == EVE_TRANSFER_READ)
262 {
263 eve_assert(3 + phost->SpiDummyBytes <= 5);
264 uint8_t spidata[5]; // FIXME: phost->SpiDummyBytes // ?
265 spidata[0] = (addr >> 16);
266 spidata[1] = (addr >> 8);
267 spidata[2] = addr & 0xff;
268 spi_open(SPIM, phost->SpiCsPin);
269 spi_writen(SPIM, spidata, 3 + phost->SpiDummyBytes);
270 phost->Status = EVE_STATUS_READING;
271 }
272 else
273 {
274 uint8_t spidata[4];
275 spidata[0] = (0x80 | (addr >> 16));
276 spidata[1] = (addr >> 8);
277 spidata[2] = addr;
278
279 spi_open(SPIM, phost->SpiCsPin);
280 spi_writen(SPIM, spidata, 3);
281
282 phost->Status = EVE_STATUS_WRITING;
283 }
284}
@ EVE_TRANSFER_READ
Definition EVE_HalDefs.h:67
static ft_uint32_t addr
Definition FT_Gpu_Hal.h:139

◆ EVE_Hal_transfer16()

uint16_t EVE_Hal_transfer16 ( EVE_HalContext phost,
uint16_t  value 
)

Write 2 bytes to Coprocessor.

Parameters
phostPointer to Hal context
valueValue to write
Returns
uint16_t Number of bytes transfered

Definition at line 374 of file EVE_HalImpl_FT9XX.c.

375{
376 uint8_t buffer[2];
377 if (phost->Status == EVE_STATUS_READING)
378 {
379 rdBuffer(phost, buffer, 2);
380 return (uint16_t)buffer[0]
381 | (uint16_t)buffer[1] << 8;
382 }
383 else
384 {
385 buffer[0] = value & 0xFF;
386 buffer[1] = value >> 8;
387 wrBuffer(phost, buffer, 2);
388 return 0;
389 }
390}
static void wrBuffer(EVE_HalContext *phost, const uint8_t *buffer, uint32_t size)
Write a block data to Coprocessor.
static void rdBuffer(EVE_HalContext *phost, uint8_t *buffer, uint32_t size)
Read a block data from Coprocessor.
unsigned short uint16_t
static ft_uint32_t ft_uint8_t * buffer
Definition FT_Gpu_Hal.h:139

◆ EVE_Hal_transfer32()

uint32_t EVE_Hal_transfer32 ( EVE_HalContext phost,
uint32_t  value 
)

Write 4 bytes to Coprocessor.

Parameters
phostPointer to Hal context
valueValue to write
Returns
uint32_t Number of bytes transfered

Definition at line 399 of file EVE_HalImpl_FT9XX.c.

400{
401 uint8_t buffer[4];
402 if (phost->Status == EVE_STATUS_READING)
403 {
404 rdBuffer(phost, buffer, 4);
405 return (uint32_t)buffer[0]
406 | (uint32_t)buffer[1] << 8
407 | (uint32_t)buffer[2] << 16
408 | (uint32_t)buffer[3] << 24;
409 }
410 else
411 {
412 buffer[0] = value & 0xFF;
413 buffer[1] = (value >> 8) & 0xFF;
414 buffer[2] = (value >> 16) & 0xFF;
415 buffer[3] = value >> 24;
416 wrBuffer(phost, buffer, 4);
417 return 0;
418 }
419}

◆ EVE_Hal_transfer8()

uint8_t EVE_Hal_transfer8 ( EVE_HalContext phost,
uint8_t  value 
)

Write 8 bits to Coprocessor.

Parameters
phostPointer to Hal context
valueValue to write
Returns
uint8_t Number of bytes transfered

Definition at line 362 of file EVE_HalImpl_FT9XX.c.

363{
364 return transfer8(phost, value);
365}
static uint8_t transfer8(EVE_HalContext *phost, uint8_t value)
Write 8 bit to Coprocessor.

◆ EVE_Hal_transferMem()

void EVE_Hal_transferMem ( EVE_HalContext phost,
uint8_t result,
const uint8_t buffer,
uint32_t  size 
)

Transfer (read/write) a block data to Coprocessor.

Parameters
phostPointer to Hal context
resultBuffer to get data transfered, NULL when write
bufferBuffer where data is transfered, NULL when read
sizeSize of buffer

Definition at line 429 of file EVE_HalImpl_FT9XX.c.

430{
431 if (!size)
432 return;
433
434 if (result && buffer)
435 {
436 /* not implemented */
438 }
439 else if (result)
440 {
441 rdBuffer(phost, result, size);
442 }
443 else if (buffer)
444 {
445 wrBuffer(phost, buffer, size);
446 }
447}
#define eve_debug_break()

◆ EVE_Hal_transferProgMem()

void EVE_Hal_transferProgMem ( EVE_HalContext phost,
uint8_t result,
eve_progmem_const uint8_t buffer,
uint32_t  size 
)

Transfer a block data from program memory.

Parameters
phostPointer to Hal context
resultBuffer to get data transfered, NULL when write
bufferBuffer where data is transfered, NULL when read
sizeSize of buffer

Definition at line 457 of file EVE_HalImpl_FT9XX.c.

458{
459 if (!size)
460 return;
461
462 if (result && buffer)
463 {
464 /* not implemented */
466 }
467 else if (result)
468 {
469 /* not implemented */
471 }
472 else if (buffer)
473 {
474 eve_assert(!((uintptr_t)buffer & 0x3)); // must be 32-bit aligned
475 eve_assert(!(size & 0x3)); // must be 32-bit aligned
477 size >>= 2;
478 while (size--)
479 {
480 uint32_t value = *(buf32++);
481 wrBuffer(phost, (uint8_t *)(&value), 4);
482 }
483 }
484}
#define eve_progmem_const

◆ EVE_Hal_transferString()

uint32_t EVE_Hal_transferString ( EVE_HalContext phost,
const char *  str,
uint32_t  index,
uint32_t  size,
uint32_t  padMask 
)

Transfer a string to EVE platform.

Parameters
phostPointer to Hal context
strString to transfer
indexStart position in the string
sizeSize of string
padMaskPadding mask
Returns
uint32_t Numer of bytes transfered

Definition at line 496 of file EVE_HalImpl_FT9XX.c.

497{
498 if (!size)
499 {
500 /* TODO: Support different padding options */
501 eve_assert(padMask == 0x3);
502 EVE_Hal_transfer32(phost, 0);
503 return 4;
504 }
505
507 uint32_t transferred = 0;
508 if (phost->Status == EVE_STATUS_WRITING)
509 {
510 transferred += (uint32_t)strnlen(str, size) + 1;
511 eve_assert(str[transferred - 1] == '\0');
512 wrBuffer(phost, (uint8_t *)str, transferred);
513 if (transferred & padMask)
514 {
515 uint32_t pad = 4 - (transferred & padMask);
516 uint8_t padding[4] = { 0 };
517 wrBuffer(phost, padding, pad);
518 transferred += pad;
519 eve_assert(!(transferred & 0x3));
520 }
521 }
522 else
523 {
524 /* not implemented */
526 }
527 return transferred;
528}
#define EVE_CMD_STRING_MAX
Definition EVE_Cmd.h:44
uint32_t EVE_Hal_transfer32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor.

◆ EVE_HalImpl_close()

void EVE_HalImpl_close ( EVE_HalContext phost)

Close a HAL context.

Parameters
phostPointer to Hal context

Definition at line 223 of file EVE_HalImpl_FT9XX.c.

224{
225 phost->Status = EVE_STATUS_CLOSED;
227#ifndef PANL_APPLET
228 spi_close(SPIM, phost->SpiCsPin);
229#endif
230}
EVE_HalPlatform g_HalPlatform
Definition EVE_Hal.c:43
@ EVE_STATUS_CLOSED
Definition EVE_HalDefs.h:57
uint32_t OpenedDevices

◆ EVE_HalImpl_defaults()

bool EVE_HalImpl_defaults ( EVE_HalParameters parameters,
size_t  deviceIdx 
)

Get the default configuration parameters.

Parameters
parametersEVE_Hal framework's parameters
deviceIdx
Returns
true True if ok
false False if error

Definition at line 116 of file EVE_HalImpl_FT9XX.c.

117{
118 parameters->PowerDownPin = GPIO_FT800_PWD;
119 parameters->SpiCsPin = deviceIdx < GPIO_SS_NB ? deviceIdx : 0; // SS0-3
120 return true;
121}
#define GPIO_SS_NB

◆ EVE_HalImpl_idle()

void EVE_HalImpl_idle ( EVE_HalContext phost)

Idle. Call regularly to update frequently changing internal state.

Parameters
phostPointer to Hal context

Definition at line 237 of file EVE_HalImpl_FT9XX.c.

238{
239 /* no-op */
240}

◆ EVE_HalImpl_initialize()

void EVE_HalImpl_initialize ( )

Initialize HAL platform.

Initialize HAL platform

Definition at line 57 of file EVE_HalImpl_FT9XX.c.

58{
59}

◆ EVE_HalImpl_open()

bool EVE_HalImpl_open ( EVE_HalContext phost,
const EVE_HalParameters parameters 
)

Opens a new HAL context using the specified parameters.

Parameters
phostPointer to Hal context
parametersEVE_Hal framework's parameters
Returns
true True if ok
false False if error

Definition at line 191 of file EVE_HalImpl_FT9XX.c.

192{
193 phost->SpiCsPin = parameters->SpiCsPin < GPIO_SS_NB ? parameters->SpiCsPin : 0;
194 phost->PowerDownPin = parameters->PowerDownPin;
195 eve_printf_debug("EVE open PWD: %d, SS: %d\n",
196 (unsigned int)phost->PowerDownPin, (unsigned int)s_SpimGpioSS[phost->SpiCsPin]);
197
198#ifdef EVE_MULTI_GRAPHICS_TARGET
199 phost->GpuDefs = &EVE_GpuDefs_FT80X;
200#endif
201
202 gpio_function(phost->PowerDownPin, pad_func_0);
203 gpio_dir(phost->PowerDownPin, pad_dir_output);
204 gpio_write(phost->PowerDownPin, 0);
205
206 /* Initialize single channel */
208
209 gpio_write(phost->PowerDownPin, 1);
210
211 /* Initialize the context variables */
212 phost->Status = EVE_STATUS_OPENED;
214
215 return true;
216}
static const uint8_t s_SpimGpioSS[4]
#define eve_printf_debug(fmt,...)

◆ EVE_HalImpl_release()

void EVE_HalImpl_release ( )

Release HAL platform.

Release HAL platform

Definition at line 65 of file EVE_HalImpl_FT9XX.c.

66{
67#ifndef PANL_APPLET
68 spi_uninit(SPIM);
69#endif
70}

◆ EVE_Mcu_initialize()

void EVE_Mcu_initialize ( )

Init FT9x host MCU.

Definition at line 720 of file EVE_HalImpl_FT9XX.c.

721{
722#ifndef PANL_APPLET
723 sys_reset_all();
724
725 interrupt_enable_globally();
726
727 sys_enable(sys_device_uart0);
728 gpio_function(GPIO_UART0_TX, pad_uart0_txd); /* UART0 TXD */
729 gpio_function(GPIO_UART0_RX, pad_uart0_rxd); /* UART0 RXD */
730 uart_open(UART0, /* Device */
731 1, /* Prescaler = 1 */
732 UART_DIVIDER_115200_BAUD, /* Divider = 1302 */
733 uart_data_bits_8, /* No. Data Bits */
734 uart_parity_none, /* Parity */
735 uart_stop_bits_1); /* No. Stop Bits */
736#endif
737
738#if (defined(ENABLE_ILI9488_HVGA_PORTRAIT) || defined(ENABLE_KD2401_HVGA_PORTRAIT))
739 /* assign all the respective pins to GPIO and set them to default values */
740 gpio_function(GPIO_ILI9488_DCX, pad_ili9488_dcx);
741 gpio_dir(GPIO_ILI9488_DCX, pad_dir_output);
742 gpio_write(GPIO_ILI9488_DCX, 1);
743
744 gpio_function(GPIO_SPIM_CLK, pad_spim_sck);
745 gpio_dir(GPIO_SPIM_CLK, pad_dir_output);
746 gpio_write(GPIO_SPIM_CLK, 1);
747
748 gpio_function(GPIO_SPIM_MOSI, pad_spim_mosi);
749 gpio_dir(GPIO_SPIM_MOSI, pad_dir_output);
750 gpio_write(GPIO_SPIM_MOSI, 1);
751
752 gpio_function(GPIO_ILI9488_CS1, pad_ili9488_cs1);
753 gpio_dir(GPIO_ILI9488_CS1, pad_dir_output);
754 gpio_write(GPIO_ILI9488_CS1, 1);
755
756 gpio_function(GPIO_SPIM_MISO, pad_spim_miso);
757 gpio_dir(GPIO_SPIM_MISO, pad_dir_output);
758 gpio_write(GPIO_SPIM_MISO, 1);
759
760 gpio_function(GPIO_SPIM_SS0, pad_spim_ss0);
761 gpio_dir(GPIO_SPIM_SS0, pad_dir_output);
762 gpio_write(GPIO_SPIM_SS0, 1);
763
764 gpio_function(GPIO_FT800_PWD, pad_func_0); /* FIXME: This needs to be done at open, not init */
765 gpio_dir(GPIO_FT800_PWD, pad_dir_output);
766 gpio_write(GPIO_FT800_PWD, 1);
767
768 gpio_write(GPIO_ILI9488_DCX, 1);
769 gpio_write(GPIO_SPIM_SS0, 1);
770 gpio_write(GPIO_FT800_PWD, 1);
771 gpio_write(GPIO_ILI9488_CS1, 1);
772#endif
773
774 initSdHost();
775}
static void initSdHost()
Sdcard initialization.

◆ EVE_Mcu_release()

void EVE_Mcu_release ( )

Release FT9x host MCU.

Definition at line 781 of file EVE_HalImpl_FT9XX.c.

782{
783 /* no-op */
784}

◆ EVE_millis()

uint32_t EVE_millis ( )

Get clock in miliseond.

Need to ensure that below api is called at least once in 6.5 seconds duration for FT900 platform as this module doesnt use timer for context update global counter to loopback after ~49.71 days

Returns
uint32_t Clock number

Definition at line 842 of file EVE_HalImpl_FT9XX.c.

843{
844#if defined(PANL_APPLET)
845 uint32_t ms = panl_timer_get_time();
847 s_TotalMilliseconds64 += (1 << 32);
849 s_TotalMilliseconds64 = (s_TotalMilliseconds64 & ~0xFFFFFFFFULL) | (uint64_t)ms;
850#endif
851 return s_TotalMilliseconds;
852}
static uint32_t s_TotalMilliseconds
static uint64_t s_TotalMilliseconds64
unsigned long long uint64_t

◆ EVE_millis64()

uint64_t EVE_millis64 ( )

Get clock in miliseond.

Need to ensure that below api is called at least once in 6.5 seconds duration for FT900 platform as this module doesnt use timer for context update global counter to loopback after ~49.71 days

Returns
uint32_t Clock number

Definition at line 862 of file EVE_HalImpl_FT9XX.c.

863{
864#if defined(PANL_APPLET)
865 uint32_t ms = panl_timer_get_time();
867 s_TotalMilliseconds64 += (1 << 32);
869 s_TotalMilliseconds64 = (s_TotalMilliseconds64 & ~0xFFFFFFFFULL) | (uint64_t)ms;
870#endif
872}

◆ EVE_Millis_initialize()

void EVE_Millis_initialize ( )

Init FT9x timer.

Definition at line 802 of file EVE_HalImpl_FT9XX.c.

803{
805#if !defined(PANL_APPLET)
806 sys_enable(sys_device_timer_wdt);
807#if defined(FT900_PLATFORM)
808 timer_prescaler(FT900_TIMER_PRESCALE_VALUE);
809#else
811#endif
812 timer_init(FT900_FT_MILLIS_TIMER, FT900_TIMER_OVERFLOW_VALUE, timer_direction_up, timer_prescaler_select_on, timer_mode_continuous);
813
814 interrupt_attach(interrupt_timers, 17, ticker);
815 /* enabling the interrupts for timer */
816 timer_enable_interrupt(FT900_FT_MILLIS_TIMER);
817
818 timer_start(FT900_FT_MILLIS_TIMER);
819#endif
820}
void ticker()
Clear the interrupt and increment the counter.
#define FT900_FT_MILLIS_TIMER
#define FT900_TIMER_PRESCALE_VALUE
#define FT900_TIMER_OVERFLOW_VALUE

◆ EVE_Millis_release()

void EVE_Millis_release ( )

Release FT9x timer.

Definition at line 826 of file EVE_HalImpl_FT9XX.c.

827{
828#if !defined(PANL_APPLET)
829 timer_stop(FT900_FT_MILLIS_TIMER);
830 timer_disable_interrupt(FT900_FT_MILLIS_TIMER);
831#endif
832}

◆ EVE_sleep()

void EVE_sleep ( uint32_t  ms)

Sleep in milisecond.

Parameters
msMilisecond

Definition at line 895 of file EVE_HalImpl_FT9XX.c.

896{
897 delayms(ms);
898}

◆ EVE_UtilImpl_bootupDisplayGpio()

bool EVE_UtilImpl_bootupDisplayGpio ( EVE_HalContext phost)

Display GPIO pins.

Parameters
phostPointer to Hal context
Returns
true True if Ok
false False if error

Definition at line 915 of file EVE_HalImpl_FT9XX.c.

916{
917 return true;
918}

◆ initSdHost()

static void initSdHost ( )
static

Sdcard initialization.

Definition at line 685 of file EVE_HalImpl_FT9XX.c.

686{
687#ifndef PANL_APPLET
688#if 1
689 /* All SD Host pins except CLK need a pull-up to work. The MM900EV*A module does not have external pull-up, so enable internal one */
690 gpio_function(GPIO_SD_CLK, pad_sd_clk);
691 gpio_pull(GPIO_SD_CLK, pad_pull_none);
692 gpio_function(GPIO_SD_CMD, pad_sd_cmd);
693 gpio_pull(GPIO_SD_CMD, pad_pull_pullup);
694 gpio_function(GPIO_SD_DAT3, pad_sd_data3);
695 gpio_pull(GPIO_SD_DAT3, pad_pull_pullup);
696 gpio_function(GPIO_SD_DAT2, pad_sd_data2);
697 gpio_pull(GPIO_SD_DAT2, pad_pull_pullup);
698 gpio_function(GPIO_SD_DAT1, pad_sd_data1);
699 gpio_pull(GPIO_SD_DAT1, pad_pull_pullup);
700 gpio_function(GPIO_SD_DAT0, pad_sd_data0);
701 gpio_pull(GPIO_SD_DAT0, pad_pull_pullup);
702 gpio_function(GPIO_SD_CD, pad_sd_cd);
703 gpio_pull(GPIO_SD_CD, pad_pull_pullup);
704 gpio_function(GPIO_SD_WP, pad_sd_wp);
705 gpio_pull(GPIO_SD_WP, pad_pull_pullup);
706
707 /* Start up the SD Card */
708 sys_enable(sys_device_sd_card);
709#else
710 sdhost_sys_init();
711#endif
712 sdhost_init();
713#endif
714}

◆ rdBuffer()

static void rdBuffer ( EVE_HalContext phost,
uint8_t buffer,
uint32_t  size 
)
inlinestatic

Read a block data from Coprocessor.

Parameters
phostPointer to Hal context
bufferBuffer to get result
sizeNumber of bytes to read

Definition at line 317 of file EVE_HalImpl_FT9XX.c.

318{
319 spi_readn(SPIM, buffer, size);
320}

◆ setSPI()

void setSPI ( EVE_HalContext phost,
EVE_SPI_CHANNELS_T  numchnls,
uint8_t  numdummy 
)

Set number of SPI channel.

Parameters
phostPointer to Hal context
numchnlsNumber of channel
numdummyNumber of dummy bytes

Definition at line 130 of file EVE_HalImpl_FT9XX.c.

131{
132 uint8_t spimGpio = s_SpimGpioSS[phost->SpiCsPin];
133 pad_dir_t spimFunc = s_SpimFuncSS[phost->SpiCsPin];
134
135 /* Reconfigure the SPI */
136 eve_assert_do(!sys_enable(sys_device_spi_master));
137 gpio_function(GPIO_SPIM_CLK, pad_spim_sck); /* GPIO27 to SPIM_CLK */
138 gpio_function(spimGpio, spimFunc); /* GPIO as SS0-SS4 */
139 gpio_function(GPIO_SPIM_MOSI, pad_spim_mosi); /* GPIO29 to SPIM_MOSI */
140 gpio_function(GPIO_SPIM_MISO, pad_spim_miso); /* GPIO30 to SPIM_MISO */
141
142 gpio_dir(GPIO_SPIM_CLK, pad_dir_output);
143 gpio_dir(spimGpio, pad_dir_output);
144 gpio_dir(GPIO_SPIM_MOSI, pad_dir_output);
145 gpio_dir(GPIO_SPIM_MISO, pad_dir_input);
146
147 if (numchnls > EVE_SPI_SINGLE_CHANNEL)
148 {
149 /* Initialize IO2 and IO3 pad/pin for dual and quad settings */
150 gpio_function(GPIO_SPIM_IO2, pad_spim_io2);
151 gpio_function(GPIO_SPIM_IO3, pad_spim_io3);
152 gpio_dir(GPIO_SPIM_IO2, pad_dir_output);
153 gpio_dir(GPIO_SPIM_IO3, pad_dir_output);
154 }
155
156 gpio_write(spimGpio, 1);
157
158 /* Change clock frequency to 25 MHz (100 MHz / 4) */
159 eve_assert_do(!spi_init(SPIM, spi_dir_master, spi_mode_0, 4));
160
161 /* Enable FIFO of QSPI */
162 spi_option(SPIM, spi_option_fifo_size, 64);
163 spi_option(SPIM, spi_option_fifo, 1);
164 spi_option(SPIM, spi_option_fifo_receive_trigger, 1);
165
166 switch (numchnls)
167 {
169 spi_option(SPIM, spi_option_bus_width, 4);
170 break;
172 spi_option(SPIM, spi_option_bus_width, 2);
173 break;
175 spi_option(SPIM, spi_option_bus_width, 1);
176 break;
177 }
178
179 phost->SpiChannels = numchnls;
180 phost->SpiDummyBytes = numdummy;
181}
@ EVE_SPI_DUAL_CHANNEL
static const pad_dir_t s_SpimFuncSS[4]
#define eve_assert_do(cond)

◆ ticker()

void ticker ( )

Clear the interrupt and increment the counter.

Definition at line 878 of file EVE_HalImpl_FT9XX.c.

879{
880#if !defined(PANL_APPLET)
882
883 timer_disable_interrupt(FT900_FT_MILLIS_TIMER);
884 /* Clear the interrupt and increment the counter */
885 timer_is_interrupted(FT900_FT_MILLIS_TIMER);
886 timer_enable_interrupt(FT900_FT_MILLIS_TIMER);
887#endif
888}

◆ transfer8()

static uint8_t transfer8 ( EVE_HalContext phost,
uint8_t  value 
)
inlinestatic

Write 8 bit to Coprocessor.

Parameters
phostPointer to Hal context
valueValue to write
Returns
uint8_t Number of bytes transfered

Definition at line 341 of file EVE_HalImpl_FT9XX.c.

342{
343 if (phost->Status == EVE_STATUS_READING)
344 {
345 spi_read(SPIM, value);
346 return value;
347 }
348 else
349 {
350 spi_write(SPIM, value);
351 return 0;
352 }
353}

◆ wrBuffer()

static void wrBuffer ( EVE_HalContext phost,
const uint8_t buffer,
uint32_t  size 
)
inlinestatic

Write a block data to Coprocessor.

Parameters
phostPointer to Hal context
bufferData buffer to write
sizeSize of buffer

Definition at line 329 of file EVE_HalImpl_FT9XX.c.

330{
331 spi_writen(SPIM, buffer, size);
332}

Variable Documentation

◆ s_SpimFuncSS

const pad_dir_t s_SpimFuncSS[4] = { pad_spim_ss0, pad_spim_ss1, pad_spim_ss2, pad_spim_ss3 }
static

Definition at line 42 of file EVE_HalImpl_FT9XX.c.

42{ pad_spim_ss0, pad_spim_ss1, pad_spim_ss2, pad_spim_ss3 };

◆ s_SpimGpioSS

const uint8_t s_SpimGpioSS[4] = { GPIO_SPIM_SS0, GPIO_SPIM_SS1, GPIO_SPIM_SS2, 35 }
static

Definition at line 41 of file EVE_HalImpl_FT9XX.c.

41{ GPIO_SPIM_SS0, GPIO_SPIM_SS1, GPIO_SPIM_SS2, 35 };

◆ s_TotalMilliseconds

uint32_t s_TotalMilliseconds = 0
static

Definition at line 792 of file EVE_HalImpl_FT9XX.c.

◆ s_TotalMilliseconds64

uint64_t s_TotalMilliseconds64 = 0
static

Definition at line 793 of file EVE_HalImpl_FT9XX.c.