# BPC **Repository Path**: libdriver/bpc ## Basic Information - **Project Name**: BPC - **Description**: 适用于通用MCU和Linux系统的BPC全功能驱动 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-13 - **Last Updated**: 2025-12-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: gpio, 电波表, BPC ## README [English](/README.md) | [ 简体中文](/README_zh-Hans.md) | [繁體中文](/README_zh-Hant.md) | [日本語](/README_ja.md) | [Deutsch](/README_de.md) | [한국어](/README_ko.md)
## LibDriver BPC [![MISRA](https://img.shields.io/badge/misra-compliant-brightgreen.svg)](/misra/README.md) [![API](https://img.shields.io/badge/api-reference-blue.svg)](https://www.libdriver.com/docs/bpc/index.html) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](/LICENSE) BPC decoding refers to the process of receiving and analyzing low-frequency radio wave time service signals issued by the National Time Service Center of the Chinese Academy of Sciences through electronic equipment. The signal transmission frequency is 68.5kHz, aiming to provide high-precision standard Beijing time automatic synchronization for radio meters, clocks, and various timing devices. LibDriver BPC is a full-featured driver for BPC, launched by LibDriver. It provides BPC decoding and additional features. LibDriver is MISRA compliant. ### Table of Contents - [Instruction](#Instruction) - [Install](#Install) - [Usage](#Usage) - [example basic](#example-basic) - [Document](#Document) - [Contributing](#Contributing) - [License](#License) - [Contact Us](#Contact-Us) ### Instruction /src includes LibDriver BPC source files. /interface includes LibDriver BPC GPIO platform independent template. /test includes LibDriver BPC driver test code and this code can test the chip necessary function simply. /example includes LibDriver BPC sample code. /doc includes LibDriver BPC offline document. /datasheet includes BPC datasheet. /project includes the common Linux and MCU development board sample code. All projects use the shell script to debug the driver and the detail instruction can be found in each project's README.md. /misra includes the LibDriver MISRA code scanning results. ### Install Reference /interface GPIO platform independent template and finish your platform GPIO driver. Add the /src directory, the interface driver for your platform, and your own drivers to your project, if you want to use the default example drivers, add the /example directory to your project. ### Usage You can refer to the examples in the /example directory to complete your own driver. If you want to use the default programming examples, here's how to use them. #### example basic ```C #include "driver_bpc_basic.h" volatile uint8_t g_flag; uint8_t (*g_gpio_irq)(void) = NULL; uint8_t res; uint32_t i; uint16_t timeout; static void a_receive_callback(bpc_t *data) { const char week[][10] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Invalid", }; switch (data->status) { case BPC_STATUS_OK : { time_t timestamp; bpc_interface_debug_print("bpc: irq ok.\n"); bpc_interface_debug_print("bpc: time is %04d-%02d-%02d %02d:%02d:%02d %s.\n", data->year, data->month, data->day, data->hour, data->minute, data->second, week[data->week > 7 ? 7 : data->week]); (void)bpc_basic_convert_timestamp(data, ×tamp); bpc_interface_debug_print("bpc: timestamp is %d.\n", timestamp); g_flag = 1; break; } case BPC_STATUS_PARITY_ERR : { bpc_interface_debug_print("bpc: irq parity error.\n"); break; } case BPC_STATUS_FRAME_INVALID : { bpc_interface_debug_print("bpc: irq frame invalid.\n"); break; } default : { bpc_interface_debug_print("bpc: irq unknown status.\n"); break; } } } /* gpio init */ res = gpio_interrupt_init(); if (res != 0) { return 1; } /* set the irq */ g_gpio_irq = bpc_basic_irq_handler; /* basic init */ res = bpc_basic_init(a_receive_callback); if (res != 0) { (void)gpio_interrupt_deinit(); g_gpio_irq = NULL; } /* set time zone */ res = bpc_basic_set_timestamp_time_zone(8); if (res != 0) { (void)gpio_interrupt_deinit(); g_gpio_irq = NULL; } ... /* loop */ for (i = 0; i < 3; i++) { /* output */ bpc_interface_debug_print("%d/%d\n", i + 1, 3); /* 60s timeout */ timeout = 6000; /* init 0 */ g_flag = 0; /* check timeout */ while (timeout != 0) { /* check the flag */ if (g_flag != 0) { break; } /* timeout -- */ timeout--; /* delay 10ms */ bpc_interface_delay_ms(10); } /* check the timeout */ if (timeout == 0) { /* receive timeout */ bpc_interface_debug_print("bpc: receive timeout.\n"); (void)bpc_basic_deinit(); (void)gpio_interrupt_deinit(); g_gpio_irq = NULL; return 1; } ... } ... /* basic deinit */ (void)bpc_basic_deinit(); /* gpio deinit */ (void)gpio_interrupt_deinit(); g_gpio_irq = NULL; return 0; ``` ### Document Online documents: [https://www.libdriver.com/docs/bpc/index.html](https://www.libdriver.com/docs/bpc/index.html). Offline documents: /doc/html/index.html. ### Contributing Please refer to CONTRIBUTING.md. ### License Copyright (c) 2015 - present LibDriver All rights reserved The MIT License (MIT) 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. ### Contact Us Please send an e-mail to lishifenging@outlook.com.