예제 #1
0
/***************************************************************************//**
  OLED_init()
  See "oled.h" for details of how to use this function.
 */
void OLED_init(void )
{
    uint8_t oled_init_sequence1[] =
    {
        OLED_COMMAND_CODE, CMD_DISPLAY_NON_INV,
        OLED_COMMAND_CODE, CMD_DISPLAY_ALL_OFF,
        OLED_COMMAND_CODE, CMD_MIRROR_HORI_ON,
        OLED_COMMAND_CODE, CMD_MIRROR_VERT_OFF,
        OLED_COMMAND_CODE, CMD_HORI_SCRL_OFF,
        OLED_COMMAND_CODE, CMD_CONTRAST,
        OLED_COMMAND_CODE, CONTRAST_DEFAULT,
        OLED_COMMAND_CODE, CMD_ARECOL_LPM,
        OLED_COMMAND_CODE, CMD_ARECOL_MONO^CMD_LPM_OFF
    };

    uint8_t oled_init_sequence2[] =
    {
        OLED_COMMAND_CODE, CMD_START_LINE,
        OLED_COMMAND_CODE, CMD_PANEL_ON
    };

    MSS_I2C_init( g_p_oled_i2c, OLED_SLAVE_ADDRESS, MSS_I2C_PCLK_DIV_60 );

    MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, oled_init_sequence1, sizeof(oled_init_sequence1), MSS_I2C_RELEASE_BUS );
    MSS_I2C_wait_complete( g_p_oled_i2c );

    OLED_clear_display(BOTH_LINES);

    MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, oled_init_sequence2, sizeof(oled_init_sequence2), MSS_I2C_RELEASE_BUS );
    MSS_I2C_wait_complete( g_p_oled_i2c );

    OLED_set_cursor( FIRST_LINE, FIRST_CHARACTER );
}
예제 #2
0
파일: gesture.c 프로젝트: hsiehju/glimpse
uint8_t wireWriteDataBlock(uint8_t reg, uint8_t* val, unsigned int len){
	MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, &reg, sizeof(reg), MSS_I2C_RELEASE_BUS);
	MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT);

	MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, val, len, MSS_I2C_RELEASE_BUS);
	MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT);
}
예제 #3
0
/***************************************************************************//**
  OLED_horizontal_scroll()
  See "oled.h" for details of how to use this function.
 */
void OLED_horizontal_scroll(struct oled_data * horiz_scroll)
{
    uint8_t horiz_scroll_on_off[] =
    {
        OLED_COMMAND_CODE, CMD_HORI_SCRL_OFF,
    };

    uint8_t horiz_scroll_setup_data[] =
    {
        OLED_COMMAND_CODE, CMD_HORI_SCRL,
        OLED_COMMAND_CODE, SCROLL_PER_STEP,
        OLED_COMMAND_CODE, SCROLL_PAGE_0,
        OLED_COMMAND_CODE, SCROLL_12_FRAMES,
        OLED_COMMAND_CODE, SCROLL_PAGE_1,
    };
    MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, horiz_scroll_on_off, sizeof(horiz_scroll_on_off), MSS_I2C_RELEASE_BUS );
    MSS_I2C_wait_complete( g_p_oled_i2c );

    if(horiz_scroll->on_off == 1)
    {
        horiz_scroll_setup_data[3] = horiz_scroll->column_scrool_per_step;
        horiz_scroll_setup_data[5] = horiz_scroll->start_page;
        horiz_scroll_setup_data[7] = horiz_scroll->time_intrval_btw_scroll_step;
        horiz_scroll_setup_data[9] = horiz_scroll->end_page;
        MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, horiz_scroll_setup_data, sizeof(horiz_scroll_setup_data), MSS_I2C_RELEASE_BUS );
        MSS_I2C_wait_complete( g_p_oled_i2c );

        horiz_scroll_on_off[1] = CMD_HORI_SCRL_ON;
        MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, horiz_scroll_on_off, sizeof(horiz_scroll_on_off), MSS_I2C_RELEASE_BUS );
        MSS_I2C_wait_complete( g_p_oled_i2c );
    }
}
예제 #4
0
uint8_t imu_read(uint8_t reg)
{
	uint8_t data;

	MSS_I2C_write
	(
		&g_mss_i2c1,
		IMU_ADDRESS_WRITE,
		&reg,
		sizeof(reg),
		MSS_I2C_RELEASE_BUS
	);

	MSS_I2C_wait_complete(&g_mss_i2c1);

	MSS_I2C_read
	(
			&g_mss_i2c1,
			IMU_ADDRESS_READ,
			&data,
			sizeof(data),
			MSS_I2C_RELEASE_BUS
	 );
	MSS_I2C_wait_complete(&g_mss_i2c1);

	return data;
}
예제 #5
0
파일: gesture.c 프로젝트: hsiehju/glimpse
void wireReadDataByte(uint8_t reg, uint8_t* val) {

	MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, &reg, sizeof(reg), MSS_I2C_RELEASE_BUS);
	MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT);

	uint8_t recieve_buf;

	MSS_I2C_read(&g_mss_i2c1, APDS9960_I2C_ADDR, &recieve_buf, sizeof(recieve_buf), MSS_I2C_RELEASE_BUS);
	MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT);

	*val = recieve_buf;
}
예제 #6
0
파일: gesture.c 프로젝트: hsiehju/glimpse
// RAW I2C FUNCTIONS
void wireWriteDataByte(uint8_t reg, uint8_t val) {

	uint8_t transmit_buf[] = {reg, val};

	MSS_I2C_write(&g_mss_i2c1, APDS9960_I2C_ADDR, transmit_buf, sizeof(transmit_buf), MSS_I2C_RELEASE_BUS);
	MSS_I2C_wait_complete(&g_mss_i2c1, MSS_I2C_NO_TIMEOUT);
}
예제 #7
0
/***************************************************************************//**
  OLED_set_cursor()
  See definition of OLED_set_cursor() for details of how to use this function.
 */
void OLED_set_cursor
(
    uint8_t line,
    uint8_t char_offset
)
{
    uint8_t command_sequence[] =
    {
        OLED_COMMAND_CODE, CMD_LOW_NIB_COL,
        OLED_COMMAND_CODE, CMD_HIGH_NIB_COL,
        OLED_COMMAND_CODE, CMD_PAGE_0
    };
    uint8_t low_nib, high_nib;

    ++char_offset;
    char_offset *= CHARACTER_WIDTH;
    low_nib = 0x0F & char_offset;
    high_nib = (0xF0 & char_offset) >> 4;
    line += 2;

    command_sequence[1] |= low_nib;
    command_sequence[3] |= high_nib;
    command_sequence[5] |= line;
    MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, command_sequence, sizeof(command_sequence), MSS_I2C_RELEASE_BUS );
    MSS_I2C_wait_complete( g_p_oled_i2c );
}
예제 #8
0
/***************************************************************************//**
  OLED_contrast()
  See "oled.h" for details of how to use this function.
 */
void OLED_contrast(uint8_t color_contrast)
{
    uint8_t oled_contrast[] =
    {
        OLED_COMMAND_CODE, CMD_CONTRAST,
        OLED_COMMAND_CODE, CONTRAST_DEFAULT,
    };

    oled_contrast[3] = color_contrast;
    MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, oled_contrast, sizeof(oled_contrast), MSS_I2C_RELEASE_BUS );
    MSS_I2C_wait_complete( g_p_oled_i2c );

}
예제 #9
0
/***************************************************************************//**
  OLED_write_char()
  See definition of OLED_write_char()  for details of how to use this function.
 */
void OLED_write_char
(
    const uint8_t data_char
)
{
    uint8_t txbuff[10];
    uint8_t i;

    for ( i = 0; i < CHARACTER_WIDTH; ++i )
    {
        txbuff[i * 2] = OLED_DATA_CODE;
        txbuff[(i * 2) + 1] = oled_ascii_character_set[data_char][i];
    }
    MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, txbuff, sizeof(txbuff), MSS_I2C_RELEASE_BUS );
    MSS_I2C_wait_complete( g_p_oled_i2c );
}
예제 #10
0
/***************************************************************************//**
  OLED_clear_display()
  See "oled.h" for details of how to use this function.
 */
void OLED_clear_display( oled_no_of_line LINES )
{
    uint8_t i, j,start_line,end_line;
    uint8_t clear_8_columns[] =
    {
        OLED_DATA_CODE, 0x00,
        OLED_DATA_CODE, 0x00,
        OLED_DATA_CODE, 0x00,
        OLED_DATA_CODE, 0x00,
        OLED_DATA_CODE, 0x00,
        OLED_DATA_CODE, 0x00,
        OLED_DATA_CODE, 0x00,
        OLED_DATA_CODE, 0x00
    };

    switch(LINES)
    {
        case FIRST_LINE:
        {
            start_line = FIRST_LINE;
            end_line = FIRST_LINE;
        }

        case SECOND_LINE:
        {
            start_line = SECOND_LINE;
            end_line = SECOND_LINE;
        }

        case BOTH_LINES:
        {
            start_line = FIRST_LINE;
            end_line = SECOND_LINE;
        }

    }

    for( j = start_line; j <= end_line; ++j )
    {
        OLED_set_cursor( j, FIRST_CHARACTER );
        for( i = 0; i < 13; ++i )
        {
            MSS_I2C_write( g_p_oled_i2c, OLED_SLAVE_ADDRESS, clear_8_columns, sizeof(clear_8_columns), MSS_I2C_RELEASE_BUS );
            MSS_I2C_wait_complete( g_p_oled_i2c );
        }
    }
}
예제 #11
0
void imu_write(uint8_t reg, uint8_t data)
{
	uint8_t transmit[2];

	transmit[0] = reg;
	transmit[1] = data;

	MSS_I2C_write
	(
		&g_mss_i2c1,
		IMU_ADDRESS_WRITE,
		transmit,
		sizeof(transmit),
		MSS_I2C_RELEASE_BUS
	);
	MSS_I2C_wait_complete(&g_mss_i2c1);
}